none
Unable to send email through c# in BizTalk orchestration RRS feed

  • Question

  • Hi Guys,

    I created a orchestration which send the mail to client if any error occurs inside orchestration.So I created a c# library and call that library from orchestration. c# code is as below :

    But after executing the code ,I got the below error:

    email id and password is correct and firewall is disable.

    Please help !


    Thanks

    Wednesday, December 28, 2016 7:20 AM

Answers

All replies

    • Marked as answer by Shivay_ Wednesday, December 28, 2016 9:08 AM
    Wednesday, December 28, 2016 7:33 AM
    Moderator
  • Hi,

    I also faced the same issue, the problem is on your username and password or the from mailId.

    You can try using the below code to test your SMTP connection.

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Net.Security;
    using System.Net.Sockets;
    using System.Text;
    using System.Threading.Tasks;
    using System;
    using System.Net.Mail;
    
    namespace SMTPConnection
    {
        class Program
        {
            static void Main(string[] args)
            {
                using (var client = new TcpClient())
                {
                    var server = "smtp.gmail.com";
                    var port = 25;
                    MailMessage mail = new MailMessage();
                    SmtpClient SmtpServer = new SmtpClient(server,port);
    
                    mail.From = new MailAddress("ahh@gmail.com");
                    mail.To.Add("ahh@gmail.com");
                    mail.To.Add("ahaboo@gmail.com");
                    mail.Subject = "Test Mail";
                    mail.Body = "This is for testing SMTP mail";
    
                    SmtpServer.Port = 25;
                    SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
                    SmtpServer.EnableSsl = true;
    
                    SmtpServer.Send(mail);
                    Console.WriteLine("mail Send");
                }
            }
        }
    }
    

    When i given the wrong password i received the following error:

    SMTP Exception

    Try using proper username and password, it should work properly.


    Regards, Aboorva Raja R Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, December 28, 2016 12:40 PM
  • Hi Shiva,

    Use the below option to send email.

    SSL TurnOn

    This url will turn on ur ssl. I tried it worked for me.



    Regards, Aboorva Raja R Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Wednesday, December 28, 2016 1:05 PM
  • For the benefit of future readers, is it not really correct to use inline classes to sent SMTP messages.

    The correct way would be using an SMTP Send Port.

    If there are gaps using the SMTP Adapter, we can help with those.

    Thursday, December 29, 2016 1:58 AM
    Moderator