31672

How can I send a multi-part email with text/plain and text/html with Exchange Web Services?

I generated a namespace with the wsdl tool via the command line by pointing it to https://exchange-server/EWS/Services.wsdl.

I'm able to successfully send emails, using the code below:

const string EWS_USERNAME = "user"; const string EWS_PASSWORD = "pass"; const string EWS_DOMAIN = "domain"; const string EWS_URL = "https://exchange-server/EWS/Exchange.asmx"; var ews = new ExchangeServiceBinding(); ews.Credentials = new NetworkCredential(EWS_USERNAME, EWS_PASSWORD, EWS_DOMAIN); ews.Url = EWS_URL; var email = new MessageType(); email.IsFromMe = false; email.From = new SingleRecipientType(); email.From.Item = new EmailAddressType(); email.From.Item.EmailAddress = "from@example.com"; email.ToRecipients = new EmailAddressType[1] { new EmailAddressType { EmailAddress = "recipient@example.com" } }; email.Subject = "Subject"; email.Body = new BodyType(); email.Body.BodyType1 = BodyTypeType.HTML; email.Body.Value = "<strong>Test</strong>"; var emailToSave = new CreateItemType(); emailToSave.Items = new NonEmptyArrayOfAllItemsType(); emailToSave.Items.Items = new ItemType[1] { email }; emailToSave.MessageDisposition = MessageDispositionType.SendAndSaveCopy; emailToSave.MessageDispositionSpecified = true; ews.CreateItemCompleted += new CreateItemCompletedEventHandler(ExchangeWebServices_CreateItemCompleted); ews.CreateItemAsync(emailToSave, callbackState);

My question is how do I send a multi-part email that contains both an HTML and plain text body?

Answer1:

Exchange generates the plain text version of you mail automatically. You don't have to do anything for that to happen.

Recommend

  • How to have two separated contacts with same email address?
  • Getting Exchange Server's users timezone
  • EWS API Delegate List
  • How to get the client IP address from the request made to webservice
  • $.ajax & passing data to .asmx webservice
  • Violates RFC 2109: host > minus domain may not contain any dots
  • Entity Framework Code First Circular Dependices
  • SecurityError for same-origin image texImage2D
  • d3 .tsv file does not work
  • Permission denied on IE using window.open()?
  • Multiple calender in exchange web service
  • Reverse output of polyfit numpy
  • RFX equivalent data type for _int64 in Informix
  • htaccess regex directory to variable
  • Camel REST Bean Chaining
  • Postgresql “no pg_hba.conf entry” error
  • Setting a Sharepoint Site Theme through a Web Service?
  • Cloud Functions for Firebase with custom HTTP path
  • something very wrong with SESSIONS
  • ERROR for site owner: Invalid site key
  • VirtualDocumentRoot handling non-existent folders
  • nginx prod setup for Clojure WebSocket app
  • Accessing Windows Azure Queues from client side javascript/jquery
  • Weighted round robin dns between 2 Cloudfront distributions
  • proxy request in node.js / express
  • PHP Copy function not working
  • Creating a DropDownList
  • jwtBearer bearer token with rc-1 update to ASP.Net 5
  • Who propagate bugfixes across branches (corporate development)?
  • Unexpected token ILLEGAL while running node.js mocha test
  • Should I or shouldn't I use the CachingConnectionFactory with hornetq 2.4.1
  • Email verification using google app script and google forms
  • Scrapy recursive link crawler
  • Is there a amazon webstore API for customers?
  • How to delete a row from a dynamic generate table using jquery?
  • Getting error when using KSoap library to consume .NET web services
  • using HTMLImports.whenReady not working in chrome
  • How do you join a server to an Active Directory (domain)?
  • Authorize attributes not working in MVC 4
  • EntityFramework adding new object to nested object collection