Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

i have been working on generating email in an event receiver using share point object model..i used the sputility.sendemail method..2 things are necessary in the email(email from and HTML body)..so i used the SpUtility method...

public static bool SendEmail(
SPWeb web,
StringDictionary messageHeaders,
string messageBody

) but this method strips any HTML present in the body..so i looked same method diff parameters..

public static bool SendEmail(
SPWeb web,
bool fAppendHtmlTag,
bool fHtmlEncode,
string to,
string subject,
string htmlBody

)

public static bool SendEmail(
SPWeb web,
bool fAppendHtmlTag,
bool fHtmlEncode,
string to,
string subject,
string htmlBody,
bool appendFooter

) the above functions do provide the html body but no 'from' parameter...how can i have both the 'from' and 'body(HTML support)' parameters..any suggestions?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

Try to specify headers in this way:

var headers = new StringDictionary();
headers.Add("subject", "Hi!");
// "text/html" to send rich html text in message body
headers.Add("content-type", "text/html");
headers.Add("to", "some@address.com");
headers.Add("from", "some@mail.com");
SPUtility.SendEmail(web, headers, "<b>Hi there!</b>");
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.