Using a custom display name when sending email through EWS

I use EWS (Exchange Web Services) with Exchange 2010 to create and send email within our organization. Currently, we have one mailbox / user for whom all our applications are sent via the app .

Generating letters is not a problem, however, when sending a test message, it is received in the recipient's mailbox with the default name in the section , regardless of the fact that the displayed name is set to code.

Code example:

 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, but it is displayed as the app account name, and not the “Test Display Name”, as indicated above in the code. See a screen shot of the inbox below:

Inbox view

This type of approach worked perfectly when using STMP services in Exchange 2003 — we could format the address as needed, for example, “Intranet-generated mail” or “Some other application," etc. Now with Exchange 2010 and EWS, it doesn't seem to allow this parameter to be used for a custom display name.

I also verified through debugging that the display name was successfully set before sending the message.

Has anyone successfully used a custom display name with EWS / Exchange 2010?

+7
source share
2 answers

I use EWS, but I never had to set the display name manually because I pre-configured it in Exchange. In other words, change the “Display” field of your “application” account in Exchange and you will not need to manually install it in your program.

-2
source

Usually method

EmailAddress ()

has an overload where you can specify a display name:

message.From = new email address (" app@company.com ", "Custom Display Name");

Try the code above and take a look.

-one
source

All Articles