Answered by:
Need Send Email Acivity in Windows workflow 4.0

Question
-
Answers
-
Hi,
Here is a email sending activity. you can also implement it as an asynchronous code activity:
using System;
Hope this helps
using System.Activities;
using System.ComponentModel;
namespace MyActivityLibrary {
public sealed class SendEmailActivity : CodeActivity {
public InArgument<string> to { get; set; }
public InArgument<string> subject { get; set; }
public InArgument<string> body { get; set; }
private string from = "*****@****.com";
private string host = "smtp.*****.com";
private string userName = "******";
private string password = "*****";
public OutArgument<string> result { get; set; }
protected override void Execute(CodeActivityContext context) {
var mailMessage = new System.Net.Mail.MailMessage();
mailMessage.To.Add(to.Get(context).ToString());
mailMessage.Subject = subject.Get(context).ToString();
mailMessage.Body = body.Get(context);
mailMessage.From = new System.Net.Mail.MailAddress(from);
var smtp = new System.Net.Mail.SmtpClient();
smtp.Host = host;
smtp.Credentials = new System.Net.NetworkCredential(userName, password);
smtp.EnableSsl = true;
smtp.Send(mailMessage);
result.Set(context, "ok");
}
}
}
Regards
MSDN Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
This posting is provided "AS IS" with no warranties, and confers no rights. My Blog: http://xhinker.com
Microsoft Windows Workflow Foundation 4.0 Cookbook- Proposed as answer by Louis Rhys Wednesday, February 9, 2011 3:15 AM
- Marked as answer by Andrew_ZhuModerator Friday, February 11, 2011 3:47 AM
-
Please check out this custom activity sample for SendMail Custom Activity.
Tim
- Marked as answer by Andrew_ZhuModerator Friday, February 11, 2011 3:47 AM
All replies
-
-
Please check out this custom activity sample for SendMail Custom Activity.
Tim
- Marked as answer by Andrew_ZhuModerator Friday, February 11, 2011 3:47 AM
-
Hi,
Here is a email sending activity. you can also implement it as an asynchronous code activity:
using System;
Hope this helps
using System.Activities;
using System.ComponentModel;
namespace MyActivityLibrary {
public sealed class SendEmailActivity : CodeActivity {
public InArgument<string> to { get; set; }
public InArgument<string> subject { get; set; }
public InArgument<string> body { get; set; }
private string from = "*****@****.com";
private string host = "smtp.*****.com";
private string userName = "******";
private string password = "*****";
public OutArgument<string> result { get; set; }
protected override void Execute(CodeActivityContext context) {
var mailMessage = new System.Net.Mail.MailMessage();
mailMessage.To.Add(to.Get(context).ToString());
mailMessage.Subject = subject.Get(context).ToString();
mailMessage.Body = body.Get(context);
mailMessage.From = new System.Net.Mail.MailAddress(from);
var smtp = new System.Net.Mail.SmtpClient();
smtp.Host = host;
smtp.Credentials = new System.Net.NetworkCredential(userName, password);
smtp.EnableSsl = true;
smtp.Send(mailMessage);
result.Set(context, "ok");
}
}
}
Regards
MSDN Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
This posting is provided "AS IS" with no warranties, and confers no rights. My Blog: http://xhinker.com
Microsoft Windows Workflow Foundation 4.0 Cookbook- Proposed as answer by Louis Rhys Wednesday, February 9, 2011 3:15 AM
- Marked as answer by Andrew_ZhuModerator Friday, February 11, 2011 3:47 AM
-
http://www.codeproject.com/Tips/640802/Create-SendEmail-Workflow-Custom-Activity
I am Sending Email By Using Above Link Code In Windows WorkFlow Console Application.
The Details Are Like This!!
Case=>1
body:"I would like to request approval to join Your Group"
DisplayName:RequestingEmail
From:"ummidikondababu83@gmail.com"
Host:"smtp.gmail.com"
Password:"********"
result:
Subject:"Approval Request"
To:"hmttrack@gmail.com"
Username:"ummidikondababu83"
Sending Mail With Above Details Is Working
Case=>2
body:"I would like to request approval to join Your Group"
DisplayName:RequestingEmail
From:"kondababuummidi@gmail.com"
Host:"smtp.gmail.com";
Password:"********"
result:
Subject:"Approval Request"
To:":"hmttrack@gmail.com"
Username:"kondababuummidi"
Sending Emal With Above Details Is Not Working
And Also For Some Email Address Also Its Not Working Why.... And Also Its Not Showing Me Any Error ..The Excecution Just Stopped After Send(EmailMessage) Function Excecutes
Please Give Me Solution and Say What I Did Wrong In This Sending Email