Reputation: 1382
I've got some .Net code I'm switching from the System.Net.MailMessage to Amazon SES and their .Net SDK v2. Is it possible to include a display name with SES using the SDK similar to the MailMessage object?
The relevant part of the old code looks something like this:
MailMessage message = new MailMessage();
MailAddress toAddress = new MailAddress(_user.Email, _user.DisplayName);
message.To.Add(toAddress);
The relevant part of the new code (so far):
SendEmailRequest request = new SendEmailRequest()
{
Source = _user.Email
};
Upvotes: 12
Views: 6649
Reputation: 75
You can set this in your App Settings or WebConfig and concatenate the name and email in your method like this:
var toAddress = $"{_configuration["AWS-SES:SenderName"]} <{_configuration["AWS-SES:SenderAddress"]}>";
its found for .NET
Upvotes: 2
Reputation: 131
Just use the .ToString() method from the MailAddress object, and you'll get the John Doe <[email protected]>
string. Send this string to AWS.
Upvotes: 3
Reputation: 22451
With the Java SDK you can include the display name in the sender
field using the format:
John Doe <[email protected]>
I assume it is the same with the .NET SDK.
Upvotes: 19