Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MAPI OLE control
Message
From
23/06/1999 18:49:37
 
 
To
23/06/1999 17:45:37
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00233147
Message ID:
00233260
Views:
25
>>Can someone please post me a sample code of how to send email message to multiple recipients using MAPI OLE control in VF6?
>>
>>I have the following working code, but it only sends to one recipient:
>>oForm = CREATEOBJECT("Form")
>>WITH oForm
>> .AddObject("Session1","olecontrol","MSMAPI.MAPISession.1")
>> .AddObject("Message1","olecontrol","MSMAPI.MAPIMessages.1")
>> .Session1.SignOn
>> .Message1.SessionID=oform.Session1.SessionID
>> .Message1.RecipDisplayName="Recipient's address here"
>> .Message1.MsgSubject="Subject here"
>> .Message1.MsgNoteText="Message here"
>> .Message1.Send
>> .Session1.SignOff
>> .Release
>>ENDWITH
>>
>>Do I have to loop through the code each time in order to send it to each recipient? Or is there a simplier way to do so?
>>
>>Thanks in advance for your help.
>>
>>CARIE
>
>Hi Carie!
>
>Your idea is good if you want to send individual letters for every one.
>
>But what about:
>.Message1.RecipDisplayName="Recipient1's address here, Recipient2's address here, ..... ,RecipientN's address here"
>
>BB

We have two processes that send reports to publishers via email. This amounts to three or four reports (depending on the process) to each of 500 + publishers.

What I did was to create a class (based on a form for reasons that become clear later) with the MAPISession Control and MAPIMessages control on the class. Added to the class are the following properties;

MessageIndex (This is always set to -1) for the purposes of these processes
RecipDisplayName
AttachFileName
AttachFilePath
AttachmentType

Added to the class are methods;

BuildEmail()
Send()

BuildEmail() validates the properties, and spawns the values to the MAPIMessages control

Send() could be omitted, but allows for a final check of the values before the message is sent. It also properly encapsulates the various calls within the object so at no point does the developer using the class have to change the hierarchy level of the object call they make.

As the process moves through generating the report files, a row is added to a table (em_ctrl.dbf) with the properties needed to send the email. RecipDisplay name is retrieved from the PublisherInformation table on SQL Server, the attachment file and path names are provided by the process control object, and the attachment type is always 0 (file). A timer counting time on the processing pc, or on another pc if you really want it to move along, checks the em_ctrl.dbf for rows that need to be sent, calls the email object filling the properties from the values in the table, and then calls the buildemail method. When it gets a good return from the buildemail method it calls send() and off the emails go.

There are other ways of doing it, but this one works very well for us. There are levels of abstraction and classing that you can leave out if you want to, but they do provide for better encapsulation and polymorphic behavior on the part of the object.

I'll be happy to help with details if you like.

Regards,

Jason
Jason Tryon
Senior Systems Analyst / Technical Lead
eBusiness / iPage
Previous
Reply
Map
View

Click here to load this message in the networking platform