API Questions on Kentico API.
Version 6.x > API > How to send mail through kentico API, so that the mail sent shows Name of the sender in outlook instead of the email-address? View modes: 
User avatar
Member
Member
shailesh.kumar.2-aonhewitt - 9/13/2012 2:12:11 AM
   
How to send mail through kentico API, so that the mail sent shows Name of the sender in outlook instead of the email-address?
Hi,

I tried sending emails through kentico api using the syntax as below in the FromEmail field,
Name<email-id>, but it failed to send the mail.

So, how can I send the mail using kentico api, so that outlood displays my name instead of the email-id.

Thanks

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 9/13/2012 3:42:04 AM
   
RE:How to send mail through kentico API, so that the mail sent shows Name of the sender in outlook instead of the email-address?
Hello,

Could you please post the exact code you are using to send out emails?

Best regards,
Boris Pocatko

User avatar
Member
Member
shailesh.kumar - dotnet - 9/13/2012 4:54:22 AM
   
RE:How to send mail through kentico API, so that the mail sent shows Name of the sender in outlook instead of the email-address?
I am filling the object like this,
EmailMessage emailMessage = new EmailMessage();
Guid EmailUniqueID = Guid.NewGuid();
emailMessage.EmailFormat = EmailFormatEnum.Html;
emailMessage.From = txtFromEmail.Text;
emailMessage.Subject = txtSubject.Text;
emailMessage.Body = cke.Value;
emailMessage.Recipients = u.SecondaryEmail;

EmailInfo info = new EmailInfo(emailMessage);
info.EmailStatus = status;
info.EmailPriority = EmailPriorityEnum.High;
info.EmailSiteID = CMSContext.CurrentSiteID;
info.EmailIsMass = isMassEmail;
info.EmailLastSendAttempt = DateTime.Now;
info.SetValue("EmailSenderUserID", fromUserId.ToString());
info.SetValue("EmailRecipientUserID", toUserId.ToString());
EmailInfoProvider.SetEmailInfo(info);

where FromEmail field is populated in database as Name<Email-ID>, but when the job runs to send the pending mails, it says, invalid email-id.

Is there any way to associate a name with the email-id while sending mail, so that the recipient of the mail can see the Name in the section From, like we see in Microsoft outlook?

Thanks

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 9/13/2012 7:57:18 AM
   
RE:How to send mail through kentico API, so that the mail sent shows Name of the sender in outlook instead of the email-address?
Hi,

in the Microsoft Outlook it's mainly the behaviour of E-mail client (show name instead of e-mail address if you have the sender saved in the Address list).

1. I don't know if you have the license of Kentico with the Source Code (in that case you can modify or extend the method ToMailMessage() in \SourceCode\EmailEngine\Emails\EmailMessage.cs). Because this method use the .NET MailAddress() function which has optional the second parameter:
new MailAddress('sender_email@domain.com', 'sender’s name')
but our in-built method ToMailMessage() uses this function only with 1 parameter.

2. There is still option to write your own EmailProvider and ovewrite the default one. You can handle it via the Global events.

Best regards,
Martin Danko

User avatar
Member
Member
shailesh.kumar - dotnet - 9/13/2012 8:07:43 AM
   
RE:How to send mail through kentico API, so that the mail sent shows Name of the sender in outlook instead of the email-address?
Thanks Martin