MailBee. NET Objects Tutorials

Send a webpage

With MailBee, you can send a web page as e-mail:

C#

msg.LoadBodyText("http://www.google.com", MessageBodyType.Html, Encoding.Default, ImportBodyOptions.ImportRelatedFiles | ImportBodyOptions.ImportRelatedFilesFromUris | ImportBodyOptions.PathIsUri);

VB.NET

msg.LoadBodyText("http://www.google.com", MessageBodyType.Html, Encoding.Default, ImportBodyOptions.ImportRelatedFiles | ImportBodyOptions.ImportRelatedFilesFromUris | ImportBodyOptions.PathIsUri)

The method call above complete loads the web page (both text and graphics) into the message body. You can find more information in LoadBodyText method documentation.

With ImportRelatedFilesFromUris flag, the files which are referenced in the message body via URLs (URIs) will be downloaded from their web locations and attached to the message. With this flag, files with local URIs (for example "/files/picture.gif" rather than "") will be attached as well. If this flag is not set, only files denoted by local file paths will be imported (e.g. "C:\picture.gif" or "files\picture.gif") while URLs will be left as-is.

In other words, ImportRelatedFilesFromUris flag allows you to make the e-mail viewable on any computer regardless of whether internet connection is available because all the required files are attached to the e-mail. This approach, however, should not be used in the case if some content of the message must always be taken from the web server (for instance, the message contains an image of the current weather forecast which is dynamically generated on each request). Having the static image attached to the message would make the forecast become out of date.