Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Set email template 'from display name' from within API View modes: 
User avatar
Member
Member
joeh42 - 9/20/2011 2:57:45 PM
   
Set email template 'from display name' from within API
When using email templates from the API, can I set the 'from' email account's 'display name', in addition to the actual email address?

Technically, I want to send an email from a generic email account for my site. But I want to dynamically set the 'from' display name. I want to set it to say 'from joe schmoe, via my site' and then, from 'jane doe via mysite' in other cases.

Thanks!
Joe Hoppe

User avatar
Member
Member
kentico_michal - 9/21/2011 2:16:43 AM
   
RE:Set email template 'from display name' from within API
Hello,

I suppose you are using the EmailSender.SendEmailWithTemplateText method:

public static void SendEmailWithTemplateText(
string siteName,
EmailMessage message,
EmailTemplateInfo template,
MacroResolver resolver,
bool sendImmediately,
string encoding
)


If so, it is possible to set the message.From property to any value you need. However, if the email template has any value specified in the From property [Site manager -> Development -> E-mail templates -> edit a template -> From], then this value is used instead of the one specified in the message.From property.

So, you need to leave the From field in email template settings empty so that the message.From value was applied.

Best regards,
Michal Legen

User avatar
Member
Member
joeh42 - 9/21/2011 12:30:20 PM
   
RE:Set email template 'from display name' from within API
The UI and API give the email template the appearance that you cannot enter a display name, but this did work for me. Thanks!