I've been tasked with writing a simple application to send emails using EWS.
I've been following the example set forth here:
http://msdn.microsoft.com/en-us/library/office/dn789003(v=exchg.150).aspx
using our exchange server address. Using this example everything is going just peachy until I attempt to send a message from a second mailbox I have access to. I am able to send messages from my own inbox without any difficulty.
I've modified the example a bit, but the essential portion is the text string representing the soap request. In that string I've attempted to add:
<t:Sender>
<t:Mailbox>
<t:EmailAddress>[email protected]</t:EmailAddress>
</t:Mailbox>
</t:Sender>
Which sends the message, but it still appears to the recipient that it came from me. I've also tried:
<t:From>
<t:Mailbox>
<t:EmailAddress>[email protected]</t:EmailAddress>
</t:Mailbox>
</t:From>
Which returns a 500 internal server error.
I can't help but feel that I'm using the wrong tag. I do have access to this mailbox through Outlook, it shows up as a second mailbox under my profile. Additionally, I've been able to send messages through this account by automating Outlook and using the "SentOnBehalfOf" property of the MailItem object, but no dice here.
We'd really like to get away from automating Outlook to send messages if we can, we've run into an issue or two lately, and this looks like it might be the last major hurdle to clear.
Thanks!
EDIT: Ok, I see that the sender tag is used for a "send on behalf of" type operation, but this still isn't quite working....