Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

Web Services Managed API

$
0
0

Hey,

I'm trying to expose some Exchange stuff through my .NET web site. It's not working because I want to use the logged in users credentials but this fails. If I hard code a username and password all is well.

My setup is:

Client > IIS 7.5 Server > Exchange 2010 Server

I know it's to do with Kerberos, but I cannot figure out where it's failing. I've setup SPNs on the Exchange server, and enable delegation on the IIS computer account in AD.

I have this working perfectly for IIS Server > SQL Server using a domain service account for SQL, so Kerberos itself appears to be sound. Same Web site, same IIS Server I'm trying to use for Exchange Web Services.

public void SendEmail_Click(object sender, EventArgs e)
{

	try
	{

		ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);

		service.UseDefaultCredentials = true;
		service.AutodiscoverUrl("User@domain.com");

		EmailMessage message = new EmailMessage(service);

		message.Subject = EmailSub_TextBox.Text;
		message.Body = EmailBod_TextBox.Text;
		message.ToRecipients.Add(EmailTo_TextBox.Text);
		message.Attachments.AddFileAttachment(String.Format("{0}", FileName), Server.MapPath(String.Format("{0}", FileUrl)));
		message.Save();
		message.SendAndSaveCopy();

	}
	catch (Exception ex)
	{

		Info_Label.Text += String.Concat(ex.Message.ToString(), "<br />");
		Info_Label.Visible = true;

	}

}

This returns this error, when for example sending an email (as per above code):

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.

The message sender (me) does have a valid mailbox!

Thanks.

PS: I have a single server Exchange environment.

Viewing all articles
Browse latest Browse all 7132

Trending Articles