S-Unit
asked on
C# EWS Exchange 2010 issue
Experts,
I have an issue regarding deploying (to a test server) an application that makes use of enterprise web services.
I have a mailing function that sends emails to clients based on the user that is logged into the system. However, these emails are required to go through Exchange.
This is where I am having an issue. The functionality is there, it does work, but for some reason, it uses the identity the app pool to send the email.
e.g. App pool is running as Domain\BloggsF.
The email is getting sent as if it was from Bloggs F.
Can some one advise on
a) Why it would do this,
b) What the solution could be?
Regards
I have an issue regarding deploying (to a test server) an application that makes use of enterprise web services.
I have a mailing function that sends emails to clients based on the user that is logged into the system. However, these emails are required to go through Exchange.
This is where I am having an issue. The functionality is there, it does work, but for some reason, it uses the identity the app pool to send the email.
e.g. App pool is running as Domain\BloggsF.
The email is getting sent as if it was from Bloggs F.
Can some one advise on
a) Why it would do this,
b) What the solution could be?
Regards
ASKER
The AppPool account is running as a specific user (in this case the an administrator called Fred Bloggs) and therefore the person does have an email address (not ideal).
I've attached a Sample.cs file, which I'm using.
The code is then used like this...
var exchange = new ExchangeHelper();
var service = exchange.InitialiseExchang eService(u serEmailAd dress);
foreach (var client in clientData)
{
if (!string.IsNullOrEmpty(cli ent.EmailA ddress))
{
try
{
data = exchange.CreateEmailAndSav e(service, userEmailAddress, new List<string>() { client.EmailAddress }, null, null, subject, body, null);
}
...........
Is this likely to be an issue in the way the account on the web server
Sample.cs
I've attached a Sample.cs file, which I'm using.
The code is then used like this...
var exchange = new ExchangeHelper();
var service = exchange.InitialiseExchang
foreach (var client in clientData)
{
if (!string.IsNullOrEmpty(cli
{
try
{
data = exchange.CreateEmailAndSav
}
...........
Is this likely to be an issue in the way the account on the web server
Sample.cs
I reckon the value of userEmailAddress is going to determine who the messages appear to come from, since that value is used to tell EWS which mailbox to connect to. But I can't see anywhere in the code that it gets assigned a value. Is there anywhere outside the parts you've already posted where it gets assigned?
ASKER
Yes,
That value (email address) is coming from data that is fetched from the database (logged on user's) when the user logs on. This is then stored as static data and, as in this case, passed as a parameter in a method.
I've checked and it does have a value assigned to it. This is the thing that's puzzling me. If a value is assigned from user A, why is it that the email sent is coming from the account that the AppPool is running under.
That value (email address) is coming from data that is fetched from the database (logged on user's) when the user logs on. This is then stored as static data and, as in this case, passed as a parameter in a method.
I've checked and it does have a value assigned to it. This is the thing that's puzzling me. If a value is assigned from user A, why is it that the email sent is coming from the account that the AppPool is running under.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry for the late reply. I've been off work with the dreaded man flu. I'll try that and get back to you. Thanks.
No problem, I hope you feel better soon.
ASKER
Sorry, I will be back at work to try this solution tomorrow.
ASKER
Thanks a lot Lee. Though I haven't solved the issue, I know now why it occurs. You were pretty much bang on. The service will use the App pool credentials. More info can be found on this post
http://social.technet.microsoft.com/Forums/en-NZ/exchangesvrdevelopment/thread/bb916d27-c903-4ec4-b623-1a29078ad9ff
http://social.technet.microsoft.com/Forums/en-NZ/exchangesvrdevelopment/thread/bb916d27-c903-4ec4-b623-1a29078ad9ff
What authentication methods do you have enabled on your EWS vdir on the target CAS server?