Microsoft Visual Studio Projects DISCUSSION

How to send an email in a visual studio [solved]

Started by syedzainnasir How to send an email in a visual studio [solved]
2 replies 248 views 2 participants
Latest activity · 20 Feb 2017

How to send an email in a visual studio [solved]

syedzainnasir Microsoft Visual Studio Projects Forum
#1
I'm trying to create a sequential workflow using VS. I'm needing to loop through all the items in a list and send an email if one of the columns equals a specific status.

I have not found any good tutorials / documentation on sending emails from a VS workflow. Has anyone done this successfully? Any help is appreciated!

using: sharepoint 2010, visual studio 2010

Thanks,

Community replies 2

Re: How to send an email in a visual studio [solved]

#2
[quote=William post_id=48 time=1487578940 user_id=64] I'm trying to create a sequential workflow using VS. I'm needing to loop through all the items in a list and send an email if one of the columns equals a specific status.

I have not found any good tutorials / documentation on sending emails from a VS workflow. Has anyone done this successfully? Any help is appreciated!

using: sharepoint 2010, visual studio 2010

Thanks, [/quote]
There is a sendEmail activity that you can drop onto the designer. It is under SharePoint Workflow group.

You should be able to add the loop, the if check, and the send email activity to the designer and just set the fields as needed.

Use SPUtility.SendEmail http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.sendemail.aspx

For example you might call it like this: [code] using System.Collections.Specialized; using Microsoft.SharePoint.Utilities; //Code defining class/WF methods, etc. //Build the headers. StringDictionary headers = new StringDictionary(); headers.Add("content-type", "text/html"); headers.Add("subject", "subject"); headers.Add("from", "from@domain.com"); headers.Add("to", "someaddress@domain.com"); SPUtility.SendEmail(item.ParentList.ParentWeb, headers, body.ToString());[/code] anyways read more : [url=http://www.theengineeringprojects.com/2013/03/how-to-send-email-in-microsoft-visual.html]How to Send Email in Microsoft Visual Studio 2010[/url]

Re: How to send an email in a visual studio [solved]

#3
[quote=Junaid_Shahid post_id=49 time=1487579146 user_id=48] [quote=William post_id=48 time=1487578940 user_id=64] I'm trying to create a sequential workflow using VS. I'm needing to loop through all the items in a list and send an email if one of the columns equals a specific status.

I have not found any good tutorials / documentation on sending emails from a VS workflow. Has anyone done this successfully? Any help is appreciated!

using: sharepoint 2010, visual studio 2010

Thanks, [/quote]
There is a sendEmail activity that you can drop onto the designer. It is under SharePoint Workflow group.

You should be able to add the loop, the if check, and the send email activity to the designer and just set the fields as needed.

Use SPUtility.SendEmail http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.utilities.sputility.sendemail.aspx

For example you might call it like this: [code] using System.Collections.Specialized; using Microsoft.SharePoint.Utilities; //Code defining class/WF methods, etc. //Build the headers. StringDictionary headers = new StringDictionary(); headers.Add("content-type", "text/html"); headers.Add("subject", "subject"); headers.Add("from", "from@domain.com"); headers.Add("to", "someaddress@domain.com"); SPUtility.SendEmail(item.ParentList.ParentWeb, headers, body.ToString());[/code] anyways read more : [url=http://www.theengineeringprojects.com/2013/03/how-to-send-email-in-microsoft-visual.html]How to Send Email in Microsoft Visual Studio 2010[/url] [/quote]
Thanks for sharing, I have solved the problem such a lovely post.
TEP COMMUNITY