Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
WebDAV .NET for Exchange
>
Tutorial
> Send message with embedded image
The following example shows you how to send HTML message with embedded image in the message body.
C# example
using System; using System.Net; using Independentsoft.Webdav.Exchange; using Independentsoft.Webdav.Exchange.ContentClass; namespace Sample { class Program { static void Main(string[] args) { NetworkCredential credential = new NetworkCredential("username", "password"); WebdavSession session = new WebdavSession(credential); session.UserMailbox = "https://myserver/exchange/emailaddress"; Resource resource = new Resource(session); Mailbox myMailbox = resource.Mailbox; Message message1 = new Message(); message1.To = "user@domain.com"; message1.Subject = "Embeded Image"; message1.HtmlDescription = "This is the message body. Below is an embedded image.
"; message1.AddAttachment("c:\\temp\\image001.gif"); MultiStatus status = resource.CreateItem(message1); string messageAddress = status.Response[0].HRef; resource.SetProperty(messageAddress + "/image001.gif", "x3712001f", "http://schemas.microsoft.com/mapi/proptag/", "image001.gif"); resource.SetProperty(messageAddress + "/image001.gif", "x370e001f", "http://schemas.microsoft.com/mapi/proptag/", "image/gif"); //Send message resource.Move(messageAddress, myMailbox.MailSubmission); } } }
VB example
Imports System Imports System.Net Imports Independentsoft.Webdav.Exchange Imports Independentsoft.Webdav.Exchange.ContentClass Module Module1 Sub Main(ByVal args() As String) Dim credential As NetworkCredential = New NetworkCredential("username", "password") Dim session As WebdavSession = New WebdavSession(credential) session.UserMailbox = "https://myserver/exchange/emailaddress" Dim resource As Resource = New Resource(session) Dim myMailbox As Mailbox = resource.Mailbox Dim message1 As Message = New Message message1.To = "user@domain.com" message1.Subject = "Embeded Image" message1.HtmlDescription = "This is the message body. Below is an embedded image.
" message1.AddAttachment("c:\\temp\\image001.gif") Dim status As MultiStatus = resource.CreateItem(message1) Dim messageAddress As String = status.Response(0).HRef resource.SetProperty(messageAddress + "/image001.gif", "x3712001f", "http://schemas.microsoft.com/mapi/proptag/", "image001.gif") resource.SetProperty(messageAddress + "/image001.gif", "x370e001f", "http://schemas.microsoft.com/mapi/proptag/", "image/gif") ' Send message resource.Move(messageAddress, myMailbox.MailSubmission) End Sub End Module