Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to issue STARTTLS command

how to issue STARTTLS command

Scheduled Pinned Locked Moved ASP.NET
helpcomtutorial
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    raghvendrapanda
    wrote on last edited by
    #1

    HY I m using de following code to send an email... protected void btnSend_Click(object sender, EventArgs e) { Response.Write("hy"); MailMessage msg = new MailMessage(); msg.To = txtTo.Text; msg.From = txtFrom.Text; msg.Subject = txtSubject.Text; msg.Body = txtContent.Value; lblStatus.Text = "Sending..."; SmtpMail.SmtpServer = "smtp.gmail.com"; SmtpMail.Send(msg); lblStatus.Text = "Sent email (" + txtSubject.Text + ") to " + txtTo.Text; } } I dnt get a run time error......5305.7.0 MUST ISSUE STARTTLS COMMAND FIRST .... plz help.. regards

    modified on Wednesday, October 29, 2008 3:27 AM

    G 2 Replies Last reply
    0
    • R raghvendrapanda

      HY I m using de following code to send an email... protected void btnSend_Click(object sender, EventArgs e) { Response.Write("hy"); MailMessage msg = new MailMessage(); msg.To = txtTo.Text; msg.From = txtFrom.Text; msg.Subject = txtSubject.Text; msg.Body = txtContent.Value; lblStatus.Text = "Sending..."; SmtpMail.SmtpServer = "smtp.gmail.com"; SmtpMail.Send(msg); lblStatus.Text = "Sent email (" + txtSubject.Text + ") to " + txtTo.Text; } } I dnt get a run time error......5305.7.0 MUST ISSUE STARTTLS COMMAND FIRST .... plz help.. regards

      modified on Wednesday, October 29, 2008 3:27 AM

      G Offline
      G Offline
      GDMFSOB
      wrote on last edited by
      #2

      I think the problem is the fact you are trying to use mail.hotmail.com try adding your Credentials to the sending, if not find a different SMTP Server public Send Mail() { MailMessage message = new MailMessage("Send to Addr", "From Address", "Subject", "Message"); message.IsBodyHtml = true; SmtpClient emailClient = new SmtpClient("Othe SMTP"); emailClient.UseDefaultCredentials = false; System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("YourSmtpUserName something@yourhost.com", "emailpassword"); emailClient.Credentials = basicAuthenticationInfo; emailClient.Send(message); }

      R H 2 Replies Last reply
      0
      • G GDMFSOB

        I think the problem is the fact you are trying to use mail.hotmail.com try adding your Credentials to the sending, if not find a different SMTP Server public Send Mail() { MailMessage message = new MailMessage("Send to Addr", "From Address", "Subject", "Message"); message.IsBodyHtml = true; SmtpClient emailClient = new SmtpClient("Othe SMTP"); emailClient.UseDefaultCredentials = false; System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("YourSmtpUserName something@yourhost.com", "emailpassword"); emailClient.Credentials = basicAuthenticationInfo; emailClient.Send(message); }

        R Offline
        R Offline
        raghvendrapanda
        wrote on last edited by
        #3

        Hy,thankz for replyng to my message....I had used aonther code ... protected void btnSend_Click(object sender, EventArgs e) { Response.Write("hy"); MailMessage msg = new MailMessage(); msg.To = txtTo.Text; msg.From = txtFrom.Text; msg.Subject = txtSubject.Text; msg.Body = txtContent.Value; lblStatus.Text = "Sending..."; SmtpMail.SmtpServer = "smtp.gmail.com"; SmtpMail.Send(msg); lblStatus.Text = "Sent email (" + txtSubject.Text + ") to " + txtTo.Text; } } i get an error dat i sould issue an STARTTLS command first...can u recommend de changes dat i should make... should i make any changes in de VIRTYAL SMTP SERVER and create a neew connection.. regards

        1 Reply Last reply
        0
        • R raghvendrapanda

          HY I m using de following code to send an email... protected void btnSend_Click(object sender, EventArgs e) { Response.Write("hy"); MailMessage msg = new MailMessage(); msg.To = txtTo.Text; msg.From = txtFrom.Text; msg.Subject = txtSubject.Text; msg.Body = txtContent.Value; lblStatus.Text = "Sending..."; SmtpMail.SmtpServer = "smtp.gmail.com"; SmtpMail.Send(msg); lblStatus.Text = "Sent email (" + txtSubject.Text + ") to " + txtTo.Text; } } I dnt get a run time error......5305.7.0 MUST ISSUE STARTTLS COMMAND FIRST .... plz help.. regards

          modified on Wednesday, October 29, 2008 3:27 AM

          G Offline
          G Offline
          GDMFSOB
          wrote on last edited by
          #4

          What .net Framework you using also add your account details to the smtpClient the code I gave you last answer works everytime.

          1 Reply Last reply
          0
          • G GDMFSOB

            I think the problem is the fact you are trying to use mail.hotmail.com try adding your Credentials to the sending, if not find a different SMTP Server public Send Mail() { MailMessage message = new MailMessage("Send to Addr", "From Address", "Subject", "Message"); message.IsBodyHtml = true; SmtpClient emailClient = new SmtpClient("Othe SMTP"); emailClient.UseDefaultCredentials = false; System.Net.NetworkCredential basicAuthenticationInfo = new System.Net.NetworkCredential("YourSmtpUserName something@yourhost.com", "emailpassword"); emailClient.Credentials = basicAuthenticationInfo; emailClient.Send(message); }

            H Offline
            H Offline
            Himanshu Manjarawala
            wrote on last edited by
            #5

            Hi, here is my code, which is same as your one. but not working as System.Net.Mail classes doesn't support SMTPS.

            SmtpClient client = new SmtpClient("smtp.gmail.com", 465);
            MailMessage mail_msg = new MailMessage();

                        MailAddress fromAdd = new MailAddress(tbFrom.Text.Trim());
                        mail\_msg.From = fromAdd;
                        mail\_msg.To.Add(new MailAddress(tbTo.Text.Trim()));
                        mail\_msg.Subject = tbSubject.Text;
                        mail\_msg.IsBodyHtml = true;
                        mail\_msg.Body = "Message From: " + tbFrom.Text.Trim() + "Subject:" + tbSubject.Text.Trim() + "Email: " + tbTo.Text.Trim() + "Content: " + tbContent.Text.Trim();
            
                        System.Net.NetworkCredential basicCredential = new System.Net.NetworkCredential(tbFrom.Text, "my password");
                        client.EnableSsl = true;
                        client.UseDefaultCredentials = false;
                        client.Credentials = basicCredential;
                        client.Send(mail\_msg);
            

            Himanshu Manjarawala. Sr. Software engineer @AutomationAnywhere http://www.himanshumbi.blogspot.com http://www.fieredotnet.wordpress.com

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups