Reputation: 3318
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?
Upvotes: 2
Views: 1771
Reputation: 5422
Exchange generates the plain text version of you mail automatically. You don't have to do anything for that to happen.
Upvotes: 3