I'm using EWS (Exchange Web Services)
with Exchange 2010
to generate and send emails internally within our organization. We currently have a single mailbox/user for which all of our applications send through called app
.
Generating emails is no problem, however when a test message is sent, it is received in the recipient's mailbox with the default account name in exchange, regardless of what display name is set in code.
Sample code:
EmailMessage message = new EmailMessage(ExchangeManager.CreateConnection());
// set from address as generic application account
message.From = new EmailAddress("app@company.com");
// set custom display name for sender email
message.From.Name = "Test Display Name";
// set send recipient as myself for testing
message.ToRecipients.Add(new EmailAddress("myaccount@company.com"));
ExchangeManager.SendExchangeMessage(message);
The message is received, however it displays as the app
account's default name, rather than "Test Display Name" as used above in code. See screenshot of outlook inbox below:
This type of approach worked fine when using Exchange 2003 STMP services - we could format the address as needed, such as "Intranet Generated Mail ", or "Some Other Application ", etc. Now with Exchange 2010 and EWS it doesn't seem to allow us this option to use a custom display name.
I have also verified through debugging that the display name is being set successfully before the message is sent.
Has anyone successfully used a custom display name with EWS / Exchange 2010?
I use EWS, but I've never had to set the Display name manually, because I configured it in Exchange beforehand. In other words, change the Display field of your "app" account in Exchange, and you won't need to manually set it in your program.