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 searching for documentation on the SP - Utilities components in visual studio 2012 with no luck.

Can anyone point me in the right direction. I am simply trying to figure out how to get the Email component working in the activity designer so I can send emails in the workflow.

Any help is appreciated.

share|improve this question
add comment

1 Answer

The below method worked in Sharepoint 2010 using Visual studio 2010.

A. Use Microsoft.SharePoint.Utilities Namespace

Do the following in your Email Activity,

B. Create an object for SendEmail class,

Ex : SendEmail sE = new SendEmail();

C. Assign from address, To address, Subject, etc, like below

Ex: sE.From = "abc@email.com"; sE.To = "xyz@email.com"; sE.CC = "xyz@email.com"; sE.Subject = "Test mail"; sE.Body = "Mail Body";

D. Declare a string Body and assign the sE.Body to it,

Ex: string body = sE.Body;

E. Then create a String Dictionary and put SendMail object into it. Ex: StringDictionary headers = new StringDictionary(); headers.Add("to", sE.To); headers.Add("cc", sE.CC); headers.Add("bcc", sE.BCC); headers.Add("from", sE.From); headers.Add("subject", sE.Subject); headers.Add("content-type", "text/html");

F. Now you can send the mail, using SPUtility.SendEmail(web, headers, body);

Ex: SPUtility.SendEmail(web, headers, body); // web --> SpWeb object.

Overload methods of SendEmail are as follows,

a. SendEmail(SPWeb, StringDictionary, String) - Sends an e-mail message.

b. SendEmail(SPWeb, StringDictionary, String, Boolean) - Sends the e-mail message to the specified address.

c. SendEmail(SPWeb, Boolean, Boolean, String, String, String) - Sends an e-mail message.

d. SendEmail(SPWeb, Boolean, Boolean, String, String, String, Boolean) - Sends the e-mail message to the specified address.

Reference,

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.sendemail(v=office.14).aspx

Note,

  1. Configure SMTP, Incoming and Outgoing emails in SharePoint Server 2010.
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.