Create and send Emails
|[Top] [Chapter] [Previous] [Next]|
Emails contain plain text, possible HTML text with images and further attachments. The creation and collection of all this data is not an easy task. If a document contains embedded images, first image files have to be created so the HTML part of the e-mail can link to them.
The TextDynamic interface IWPMAPI makes it easy to prepare the e-mail data. You are then free to either use the MapiSendMail function to send it (call Send) or you can read the properties and send the e-mail using a different tool. In this case you only have to interpret the list provided by AttachmentList.
When you execute Prepare the e-mail will be created, all attachments will be written. By default the e-mail will be created with the body as ANSI text and the document as HTML attachment. If you want the e-mail body to be HTML formatted text, first assign the string "<html>" to the property Body .
Body: The body as ANSI text, assign <html> to force HTML creation, assign "" to let the component create ANSI text. You can also assign some ANSI text will be then used as text body.
AddHTML: if true (default) the document will be appended as HTML attachment.
AttachmentList: the attachment files as list of filename=displayname pairs, delimited by comma. Prepare clears this list and adds the name of the HTML message and all images. If you want to add other files you can use AppendFile after preparing.
Prepare: Collect the data for an e-mail. This clears the attachment list.
Send: Send the e-mail which was prepared last. If no e-mail was prepared the document from editor 1 will be send.
Send2: Send the e-mail which was prepared last. If no e-mail was prepared the document from editor 2 will be send.
mapi = wpdllInt1.MAPI;
mapi.Recipients = "firstname.lastname@example.org";
mapi.Subject = "Test me";
mapi.Body = "<html>";
"MAPI created this attachments");