PWEmbedImageSMTP class
The PWEmbedSMTP subclass works with the PWStyleHTMLField to enable sending email messages that have embedded images, and therefore do not require posting images for email messages on a Web server.

Usage
PWEmbedSMTP is very simple to use, with only one function you might possibly want to take advantage of. There are a few requirements to keep in mind for using it properly.

To send email messages with embedded images, you must:
  1. Add image files as EmailAttachment instances to the EmailMessage instance you're sending
  2. Add a PWEmbedSMTP instance in your REALbasic/REALStudio project
  3. Send the EmailMessage via the PWEmbedSMTP class instance
  4. Set the PWEmbedSMTP class's EmbedImages property to true.

In order for it to work properly, images must be added to your message's HTML with correct formatting. Perhaps most importantly, the name of the image file must be enclosed in quotation marks.

If the EmbedImages property is not set to true, any attached files will be sent as normal email attachments.

If the EmbedImages property is set to true but you add file attachments without references in the message email, the attachments are added to the unreferenced message as normal attachments. However they may not be accessible to the recipient by normal means depending on the behavior of the receiving email client.

Out of the box, PWEmbedSMTP class supports the following image file types:
  • JPEG (with a "".jpg"" or ""jpeg"" file extension)
  • PNG
  • GIF

If the EmbedImages property is set to true and you attach any non-image files, they will not be attached to the message, unless you have told the PWEmbedSMTP instance to add a filetype for that attachment, using the AddAttachmentFileType function.

PWEmbedImage Functions
AddAttachmentFileType: Parameters: extension As String, mimeType As String Returns : A Boolean to indicate whether the file type was successfully added. The extension should be the file extension (e.g. ""zip"", ""exe"", ""doc""). You can include the leading period if you like. The mimeType parameter should be the mime type for that file type (e.g. ""application/zip"" for a zip file). You can use this function to add image file types that PWEmbedSMTP does not support out of the box, or to handle other types of attachments your message might include. Using this function to add a file type for one that is already supported is harmless.

Properties
DisableBackgroundTasks: Boolean. Turns the DisableBackgroundTasks pragma on or off in methods and functions with loops. Setting it to True makes operation speedier but makes your application's user interface less responsive.

EmbedImages: Boolean. When set to True, the socket instance alters an email's BodyHTML text to embed all images attached to the message within the message body. If set to False, the image files are included as normal attachments.

Using the Send Email Demo with Embedded Images
To send email messages with embedded images in a RealBasic/Real Studio project, you need to add image files as attachments to your EmailMessage instance and add references to the files to the message's HTML. With the demo, you do both with the Insert Image button. Note that this button is enabled only if the Embed Email images checkbox is checked, and the insertion point is in the "message" text area.

Click the button and choose an image file to include by clicking Choose in the dialog that appears (or drag a file from the Finder or desktop/Windows Explorer). You can add Alt and Title tags if you like. Click OK to add the file to your attachment list and insert it at the message text's insertion point.