none
Need Send Email Acivity in Windows workflow 4.0 RRS feed

  • Question

  • Hi ,

    I am looking for Send Email Acvity in my Worklfow 4.0. But It is not in my toolbox.

    It was in Windows workflow 3.5 .

    Can anyone please tell me how can I use Send email activity in Windows worflow 4.0.

    Thanks

    Arun Singh

    Friday, February 4, 2011 6:51 AM

Answers

  • Hi,

    Here is a email sending activity. you can also implement it as an asynchronous code activity:
    using System;
    using System.Activities;
    using System.ComponentModel;

    namespace MyActivityLibrary {
        public sealed class SendEmailActivity : CodeActivity {
            public InArgument<string> to { getset; }
            public InArgument<string> subject { getset; }
            public InArgument<string> body { getset; }
            private string from = "*****@****.com";
            private string host = "smtp.*****.com";
            private string userName = "******";
            private string password = "*****";
            public OutArgument<string> result { getset; }

            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");
            }
        }
    }
    Hope this helps
    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
    Wednesday, February 9, 2011 2:55 AM
    Moderator
  • Please check out this custom activity sample for SendMail Custom Activity.

    Tim

    Friday, February 4, 2011 8:39 AM
    Moderator

All replies

  • guys please reply ....

    is there any way to send the notification to user by workflow

    Friday, February 4, 2011 8:22 AM
  • Please check out this custom activity sample for SendMail Custom Activity.

    Tim

    Friday, February 4, 2011 8:39 AM
    Moderator
  • Hi,

    Here is a email sending activity. you can also implement it as an asynchronous code activity:
    using System;
    using System.Activities;
    using System.ComponentModel;

    namespace MyActivityLibrary {
        public sealed class SendEmailActivity : CodeActivity {
            public InArgument<string> to { getset; }
            public InArgument<string> subject { getset; }
            public InArgument<string> body { getset; }
            private string from = "*****@****.com";
            private string host = "smtp.*****.com";
            private string userName = "******";
            private string password = "*****";
            public OutArgument<string> result { getset; }

            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");
            }
        }
    }
    Hope this helps
    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
    Wednesday, February 9, 2011 2:55 AM
    Moderator
  • 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
    Saturday, December 20, 2014 6:42 AM