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

You can post your problem related to Microsoft Visual Studio Projects here. We will try our best to help you out.
Post Reply
William
Posts:11
Joined:Mon Feb 20, 2017 8:21 am
How to send an email in a visual studio [solved]

Post by William » Mon Feb 20, 2017 8:22 am

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,

Junaid_Shahid
Posts:110
Joined:Tue Feb 14, 2017 9:00 am

Re: How to send an email in a visual studio

Post by Junaid_Shahid » Mon Feb 20, 2017 8:25 am

William wrote:
Mon Feb 20, 2017 8:22 am
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,
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 ... email.aspx

For example you might call it like this:

Code: Select all

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());
anyways read more : How to Send Email in Microsoft Visual Studio 2010

William
Posts:11
Joined:Mon Feb 20, 2017 8:21 am

Re: How to send an email in a visual studio

Post by William » Mon Feb 20, 2017 8:28 am

Junaid_Shahid wrote:
Mon Feb 20, 2017 8:25 am
William wrote:
Mon Feb 20, 2017 8:22 am
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,
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 ... email.aspx

For example you might call it like this:

Code: Select all

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());
anyways read more : How to Send Email in Microsoft Visual Studio 2010
Thanks for sharing, I have solved the problem such a lovely post.

Post Reply