Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sending email via FoxPro
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00430782
Message ID:
00431198
Views:
13
If you're on NT or 2000 you can use collaborative data objects (CDO and CDONT) for a really nice interface.

You might also look at sending the addresses to an Outlook contact folder so you have more flexibility. Here is a code sample that pulls e-mail addresses out of one of our tables and makes sorted groups in Outlook:

close all
clear all
release all
clear
set exclusive off
set talk on

local loOL, loNS, loContacts, loNewFldr
local loCurrDptFldr, loCurrCatFldr, loCurrItmFldr, loNewContact
local loRecipients, loDistList, loMail
local lcSaveDpt, lcSaveCat, lcSaveItm

&&set step on

&&IT'S BEST IF OUTLOOK IS ALREADY STARTED OR YOU WILL HAVE TO START IT TWICE

loOL=createobject('outlook.application')
loNS=loOL.GetNameSpace("MAPI")
loContacts=loNS.GetDefaultFolder(10) &&10=olFolderContacts

&&delete from last time...
for lnI=1 to loContacts.Folders.Count
if loContacts.Folders.Item(lnI).Name="Sirius Passholders 1998-9"
loContacts.Folders.Remove(lnI)
endif
endfor

loNewFldr=loContacts.Folders.Add("Sirius Passholders 1998-9")

&&set path to "\\ntserver\f-drive\sirius.fs\data\shared_c\"
set path to d:\sirius.fs\data\dev_shared_c
use gst_pass shared in 0
use guests shared in 0

select g.first_name, g.last_name, g.phone, g.e_mail,;
p.department, p.category, p.item;
from guests g, gst_pass p;
into cursor outlook1;
where g.guest_no=p.guest_no and;
!g.check_bx2 and;
at('@',g.e_mail)>0 and at('.',g.e_mail)>0 and;
!p.department=='EMPLOYEE ';
order by p.department, p.category, p.item

lcSaveDpt=''
lcSaveCat=''
lcSaveItm=''
go top
scan
&&group distribution lists per department
if !department==lcSaveDpt
&&put mailing list from previous loop in dist list
if vartype(loDistList)='O' and vartype(loRecipients)='O'
loRecipients.ResolveAll()
loDistList.AddMembers(loRecipients)
loDistList.Save()
endif

loDistList=loNewFldr.Items.Add(7) &&olDistributionListItem
loDistList.DLName=department

loMail=loOL.createitem(0) &&olMailItem (bug workaround!!!)
loRecipients=loMail.Recipients
endif

if !department==lcSaveDpt &&create folder tree
loCurrDptFldr=loNewFldr.Folders.Add(department)
lcSaveDpt=department
endif
if !department+category==lcSaveDpt+lcSaveCat
loCurrCatFldr=loCurrDptFldr.Folders.Add(category)
lcSaveCat=category
endif
if !department+category+item==lcSaveDpt+lcSaveCat+lcSaveItm
loCurrItmFldr=loCurrCatFldr.Folders.Add(item)
lcSaveItm=item
endif

&&add as a contact
loNewContact=loCurrItmFldr.Items.Add()
loNewContact.HomeTelephoneNumber=alltrim(phone)
loNewContact.Email1Address=alltrim(e_mail)
loNewContact.FirstName=alltrim(first_name)
loNewContact.LastName=alltrim(last_name)
loNewContact.FullName=alltrim(first_name)+' '+alltrim(last_name)
loNewContact.Save()

&&add to distribution list
loRecipients.Add(loNewContact.Email1Address)
endscan

&&put mailing list from previous loop in dist list
if vartype(loDistList)='O' and vartype(loRecipients)='O'
loRecipients.ResolveAll()
loDistList.AddMembers(loRecipients)
loDistList.Save()
endif
Previous
Reply
Map
View

Click here to load this message in the networking platform