Hello stackoverflowers!
I'm using Exchange Web Service exposed from exchange 2007 SP1 server to create emails from my application and I've encounted a problem I can't figure out.
I get this response "When making a request as an account that does not have a mailbox, you must specify the mailbox primary SMTP address for any distinguished folder Ids." everytime I try to CreateItem()
from a web application.
This only happens on a Windows 2003 + IIS6 when UseDefaultCredentials = True
. But it's fine if I set the credentials with New System.Net.NetworkCredential("user","password")
. The latter is not an option in production.
The strangest thing is that UseDefaultCredentials = True
works if I run it from VS2008 on my local machine (but the exchange server is the same remote machine). What is wrong?
To make this more readable I've pasted a code example that uses Exchange WS API 1.0 here below. But it's the same problem if I use the Exchange WS directly.
Dim serviceObj As ExchangeService = _
New ExchangeService(ExchangeVersion.Exchange2007_SP1)
serviceObj.UseDefaultCredentials = True
serviceObj.Url = New Uri(serviceUrl)
Dim message = New EmailMessage(serviceObj)
message.Subject = "Greetings"
message.Body = New MessageBody(BodyType.Text, "Hello World")
message.ToRecipients.Add("[email protected]")
message.SendAndSaveCopy()
Thankful for any thoughts.