locked
How to send Email with/without attachments using WCF Service RRS feed

  • Question

  • User-426648087 posted

    Hi ,

     I am newbie to wcf service can anyone help me from the scratch to send mail using wcf service. i have googled it but i can't get the clear concept of this. Please help me out.

    Thank you so much in advance..!!

    Saturday, August 17, 2013 6:09 AM

Answers

  • User220959680 posted

    send mail using wcf service

    Step by step tutorial : WCF Service to send Email with attachments

    Let us know further queries.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 17, 2013 11:17 AM
  • User220959680 posted

    change the client application to web form then should i need to make changes in the wcf service.

    No.

    The service is providing the required functionality. Refer the below

     public int SendEmail(string gmailUserAddress, string gmailUserPassword, string[] emailTo, 
              string[] ccTo, string subject, string body, bool isBodyHtml, FileAttachment[] attachments)
            {



    need to mention the recepient email address, subject and  body of the message at the runtime.

    As long as the existing web service is providing the operation (function) there is no need to change the service. Web form application simply consumes the service by providing the required parameters to the service. In the suggested article the client is windows console application, in your requirement it is 'web forms'. 

    Note: Please post a new thread for further response.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 19, 2013 5:50 AM

All replies

  • User-776477372 posted

    Hi Amarnath,

    public static void sendMail(string to, string from, string subject, string body)
    {
    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(from, to);
    msg.Subject = subject;
    msg.IsBodyHtml = true;
    msg.Body = body;
    msg.IsBodyHtml = true;
    System.Net.Mail.SmtpClient oSmtpClient = new System.Net.Mail.SmtpClient("localhost");
    oSmtpClient.Send(msg);
    }

    Saturday, August 17, 2013 7:09 AM
  • User-776477372 posted

    Or,

    private void sendErrorEmail(string sub, string errormsg)
    {
    string from = "abc@gmail.com";
    string to = "xyz@gmail.com";
    System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(from, to);
    msg.Subject = sub;
    msg.IsBodyHtml = true;
    msg.Body = errormsg;
    System.Net.Mail.SmtpClient oSmtpClient = new System.Net.Mail.SmtpClient("localhost");
    oSmtpClient.Send(msg);
    }

    Saturday, August 17, 2013 7:11 AM
  • User220959680 posted

    send mail using wcf service

    Step by step tutorial : WCF Service to send Email with attachments

    Let us know further queries.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, August 17, 2013 11:17 AM
  • User-426648087 posted

    Thank you so much for the tutorial.

    if i need to change the client application to web form then should i need to make changes in the wcf service.

    Because i need to mention the recepient email address, subject and  body of the message at the runtime. please clarify me in this. thank you so much in advance. 

    Monday, August 19, 2013 2:17 AM
  • User220959680 posted

    change the client application to web form then should i need to make changes in the wcf service.

    No.

    The service is providing the required functionality. Refer the below

     public int SendEmail(string gmailUserAddress, string gmailUserPassword, string[] emailTo, 
              string[] ccTo, string subject, string body, bool isBodyHtml, FileAttachment[] attachments)
            {



    need to mention the recepient email address, subject and  body of the message at the runtime.

    As long as the existing web service is providing the operation (function) there is no need to change the service. Web form application simply consumes the service by providing the required parameters to the service. In the suggested article the client is windows console application, in your requirement it is 'web forms'. 

    Note: Please post a new thread for further response.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, August 19, 2013 5:50 AM