How to send email with vs2005?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Q2hlZg==?=

    How to send email with vs2005?

    I can use outlook2003 to send email,but I cann't use this code below to send
    email.
    Please help me to test this code and instruct me how to solve this problem
    in detail.



    software environment: VS2005 + XP.-- I have disabled firewall
    hardware enviornmnet:t elcom's modem connects hub,hub connects two
    computers.。-- I also tried to connect computer to modem directly,but I can
    surf internet, not send email with code.

    =============== ==============
    System.Net.Mail .SmtpClient client = new SmtpClient();
    client.Host = "smtp.gmail.com ";
    client.Port = 465;
    client.UseDefau ltCredentials = false;
    client.Credenti als = new System.Net.Netw orkCredential(" uid", "pwd");
    //I also try to use full email address to replace uid. It didn't work.
    client.Delivery Method = SmtpDeliveryMet hod.Network;

    System.Net.Mail .MailMessage message = new
    MailMessage("ui d@hotmail.com", "uid@hotmail.co m", "Subject",

    "Body");
    message.BodyEnc oding = System.Text.Enc oding.UTF8;
    message.IsBodyH tml = true;

    try
    {
    client.Send(mes sage);
    Response.Write( "Email successfully sent.");
    }
    catch (Exception ex)
    {
    Response.Write( "Send Email Failed." + ex.ToString()); ;
    }
    ===============
  • =?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBN

    #2
    RE: How to send email with vs2005?

    Is your logon name "uid" and your password "pwd"? If not, change these values
    to your logon id and password. That should get things running.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA

    *************** ************
    Think Outside the Box!
    *************** ************


    "Chef" wrote:
    I can use outlook2003 to send email,but I cann't use this code below to send
    email.
    Please help me to test this code and instruct me how to solve this problem
    in detail.
    >
    >
    >
    software environment: VS2005 + XP.-- I have disabled firewall
    hardware enviornmnet:t elcom's modem connects hub,hub connects two
    computers.。-- I also tried to connect computer to modem directly,but I can
    surf internet, not send email with code.
    >
    =============== ==============
    System.Net.Mail .SmtpClient client = new SmtpClient();
    client.Host = "smtp.gmail.com ";
    client.Port = 465;
    client.UseDefau ltCredentials = false;
    client.Credenti als = new System.Net.Netw orkCredential(" uid", "pwd");
    //I also try to use full email address to replace uid. It didn't work.
    client.Delivery Method = SmtpDeliveryMet hod.Network;
    >
    System.Net.Mail .MailMessage message = new
    MailMessage("ui d@hotmail.com", "uid@hotmail.co m", "Subject",
    >
    "Body");
    message.BodyEnc oding = System.Text.Enc oding.UTF8;
    message.IsBodyH tml = true;
    >
    try
    {
    client.Send(mes sage);
    Response.Write( "Email successfully sent.");
    }
    catch (Exception ex)
    {
    Response.Write( "Send Email Failed." + ex.ToString()); ;
    }
    ===============

    Comment

    • Mark Rae

      #3
      Re: How to send email with vs2005?

      "Chef" <Chef@discussio ns.microsoft.co mwrote in message
      news:7A8A6D47-6E48-4767-B7B9-201A75C691DF@mi crosoft.com...
      but I cann't use this code below to send email.
      What happens when you try...?


      Comment

      • =?Utf-8?B?Q2hlZg==?=

        #4
        RE: How to send email with vs2005?

        I used my real user name and password to replace "uid" and "pwd" in the code.

        "Cowboy (Gregory A. Beamer) - MVP" wrote:
        Is your logon name "uid" and your password "pwd"? If not, change these values
        to your logon id and password. That should get things running.
        >
        --
        Gregory A. Beamer
        MVP; MCP: +I, SE, SD, DBA
        >
        *************** ************
        Think Outside the Box!
        *************** ************
        >
        >
        "Chef" wrote:
        >
        I can use outlook2003 to send email,but I cann't use this code below to send
        email.
        Please help me to test this code and instruct me how to solve this problem
        in detail.



        software environment: VS2005 + XP.-- I have disabled firewall
        hardware enviornmnet:t elcom's modem connects hub,hub connects two
        computers.。-- I also tried to connect computer to modem directly,but I can
        surf internet, not send email with code.

        =============== ==============
        System.Net.Mail .SmtpClient client = new SmtpClient();
        client.Host = "smtp.gmail.com ";
        client.Port = 465;
        client.UseDefau ltCredentials = false;
        client.Credenti als = new System.Net.Netw orkCredential(" uid", "pwd");
        //I also try to use full email address to replace uid. It didn't work.
        client.Delivery Method = SmtpDeliveryMet hod.Network;

        System.Net.Mail .MailMessage message = new
        MailMessage("ui d@hotmail.com", "uid@hotmail.co m", "Subject",

        "Body");
        message.BodyEnc oding = System.Text.Enc oding.UTF8;
        message.IsBodyH tml = true;

        try
        {
        client.Send(mes sage);
        Response.Write( "Email successfully sent.");
        }
        catch (Exception ex)
        {
        Response.Write( "Send Email Failed." + ex.ToString()); ;
        }
        ===============

        Comment

        • =?Utf-8?B?Q2hlZg==?=

          #5
          Re: How to send email with vs2005?

          It happend below!

          "Send Email Failed.System.N et.Mail.SmtpExc eption: The operation has timed
          out. at System.Net.Mail .SmtpClient.Sen d(MailMessage message) at
          MainPage.Button 1_Click(Object sender, EventArgs e) in c:\Programming in
          Class\ThreePage s\MainPage.aspx .cs:line 94 "

          "Mark Rae" wrote:
          "Chef" <Chef@discussio ns.microsoft.co mwrote in message
          news:7A8A6D47-6E48-4767-B7B9-201A75C691DF@mi crosoft.com...
          >
          but I cann't use this code below to send email.
          >
          What happens when you try...?
          >
          >
          >

          Comment

          • Mark Rae

            #6
            Re: How to send email with vs2005?

            "Chef" <Chef@discussio ns.microsoft.co mwrote in message
            news:FFFFBF05-2723-4296-9E97-7FAC4FF7291B@mi crosoft.com...
            "Send Email Failed.System.N et.Mail.SmtpExc eption: The operation has timed
            out. at System.Net.Mail .SmtpClient.Sen d(MailMessage message) at
            MainPage.Button 1_Click(Object sender, EventArgs e) in c:\Programming in
            Class\ThreePage s\MainPage.aspx .cs:line 94 "
            Indulge me - what does line 94 contain...? I'm assuming it's:

            client.Send(mes sage);


            Comment

            • =?Utf-8?B?Q2hlZg==?=

              #7
              Re: How to send email with vs2005?

              client.Send(mes sage); //line 94

              "Mark Rae" wrote:
              "Chef" <Chef@discussio ns.microsoft.co mwrote in message
              news:FFFFBF05-2723-4296-9E97-7FAC4FF7291B@mi crosoft.com...
              >
              "Send Email Failed.System.N et.Mail.SmtpExc eption: The operation has timed
              out. at System.Net.Mail .SmtpClient.Sen d(MailMessage message) at
              MainPage.Button 1_Click(Object sender, EventArgs e) in c:\Programming in
              Class\ThreePage s\MainPage.aspx .cs:line 94 "
              >
              Indulge me - what does line 94 contain...? I'm assuming it's:
              >
              client.Send(mes sage);
              >
              >
              >

              Comment

              • sloan

                #8
                Re: How to send email with vs2005?


                I have downloadable examples here:

                2/8/2006
                Smarter Email/Smtp setup with DotNet Configuration Sections (1.1 and 2.0)



                "Chef" <Chef@discussio ns.microsoft.co mwrote in message
                news:7A8A6D47-6E48-4767-B7B9-201A75C691DF@mi crosoft.com...
                I can use outlook2003 to send email,but I cann't use this code below to
                send
                email.
                Please help me to test this code and instruct me how to solve this problem
                in detail.
                >
                >
                >
                software environment: VS2005 + XP.-- I have disabled firewall
                hardware enviornmnet:tel com's modem connects hub,hub connects two
                computers.?-- I also tried to connect computer to modem directly,but I can
                surf internet, not send email with code.
                >
                =============== ==============
                System.Net.Mail .SmtpClient client = new SmtpClient();
                client.Host = "smtp.gmail.com ";
                client.Port = 465;
                client.UseDefau ltCredentials = false;
                client.Credenti als = new System.Net.Netw orkCredential(" uid",
                "pwd");
                //I also try to use full email address to replace uid. It didn't work.
                client.Delivery Method = SmtpDeliveryMet hod.Network;
                >
                System.Net.Mail .MailMessage message = new
                MailMessage("ui d@hotmail.com", "uid@hotmail.co m", "Subject",
                >
                "Body");
                message.BodyEnc oding = System.Text.Enc oding.UTF8;
                message.IsBodyH tml = true;
                >
                try
                {
                client.Send(mes sage);
                Response.Write( "Email successfully sent.");
                }
                catch (Exception ex)
                {
                Response.Write( "Send Email Failed." + ex.ToString()); ;
                }
                ===============

                Comment

                • =?Utf-8?B?Q2hlZg==?=

                  #9
                  Re: How to send email with vs2005?

                  Thank you very much.

                  Your code is really helpfull. It worked with port 587, not 465 on my pc. One
                  more thing, could you tell me what the problem is with my code?


                  "sloan" wrote:
                  >
                  I have downloadable examples here:
                  >
                  2/8/2006
                  Smarter Email/Smtp setup with DotNet Configuration Sections (1.1 and 2.0)

                  >
                  >
                  "Chef" <Chef@discussio ns.microsoft.co mwrote in message
                  news:7A8A6D47-6E48-4767-B7B9-201A75C691DF@mi crosoft.com...
                  I can use outlook2003 to send email,but I cann't use this code below to
                  send
                  email.
                  Please help me to test this code and instruct me how to solve this problem
                  in detail.



                  software environment: VS2005 + XP.-- I have disabled firewall
                  hardware enviornmnet:tel com's modem connects hub,hub connects two
                  computers.?-- I also tried to connect computer to modem directly,but I can
                  surf internet, not send email with code.

                  =============== ==============
                  System.Net.Mail .SmtpClient client = new SmtpClient();
                  client.Host = "smtp.gmail.com ";
                  client.Port = 465;
                  client.UseDefau ltCredentials = false;
                  client.Credenti als = new System.Net.Netw orkCredential(" uid",
                  "pwd");
                  //I also try to use full email address to replace uid. It didn't work.
                  client.Delivery Method = SmtpDeliveryMet hod.Network;

                  System.Net.Mail .MailMessage message = new
                  MailMessage("ui d@hotmail.com", "uid@hotmail.co m", "Subject",

                  "Body");
                  message.BodyEnc oding = System.Text.Enc oding.UTF8;
                  message.IsBodyH tml = true;

                  try
                  {
                  client.Send(mes sage);
                  Response.Write( "Email successfully sent.");
                  }
                  catch (Exception ex)
                  {
                  Response.Write( "Send Email Failed." + ex.ToString()); ;
                  }
                  ===============
                  >
                  >
                  >

                  Comment

                  • =?Utf-8?B?Q2hlZg==?=

                    #10
                    Re: How to send email with vs2005?

                    If I use gmail as smtp server, what the different between port 587 and port
                    465 is?

                    I just check gmail online help, it recommend that we use port 465. Why? Waht
                    is the reason you used port 587?

                    Thanks in advance!

                    "sloan" wrote:
                    >
                    I have downloadable examples here:
                    >
                    2/8/2006
                    Smarter Email/Smtp setup with DotNet Configuration Sections (1.1 and 2.0)

                    >
                    >
                    "Chef" <Chef@discussio ns.microsoft.co mwrote in message
                    news:7A8A6D47-6E48-4767-B7B9-201A75C691DF@mi crosoft.com...
                    I can use outlook2003 to send email,but I cann't use this code below to
                    send
                    email.
                    Please help me to test this code and instruct me how to solve this problem
                    in detail.



                    software environment: VS2005 + XP.-- I have disabled firewall
                    hardware enviornmnet:tel com's modem connects hub,hub connects two
                    computers.?-- I also tried to connect computer to modem directly,but I can
                    surf internet, not send email with code.

                    =============== ==============
                    System.Net.Mail .SmtpClient client = new SmtpClient();
                    client.Host = "smtp.gmail.com ";
                    client.Port = 465;
                    client.UseDefau ltCredentials = false;
                    client.Credenti als = new System.Net.Netw orkCredential(" uid",
                    "pwd");
                    //I also try to use full email address to replace uid. It didn't work.
                    client.Delivery Method = SmtpDeliveryMet hod.Network;

                    System.Net.Mail .MailMessage message = new
                    MailMessage("ui d@hotmail.com", "uid@hotmail.co m", "Subject",

                    "Body");
                    message.BodyEnc oding = System.Text.Enc oding.UTF8;
                    message.IsBodyH tml = true;

                    try
                    {
                    client.Send(mes sage);
                    Response.Write( "Email successfully sent.");
                    }
                    catch (Exception ex)
                    {
                    Response.Write( "Send Email Failed." + ex.ToString()); ;
                    }
                    ===============
                    >
                    >
                    >

                    Comment

                    • sloan

                      #11
                      Re: How to send email with vs2005?


                      I have no idea.

                      Experimentation showed that for 1.1 .. one of those ports worked.
                      and for 2.0, only the other one worked.
                      ????

                      Huh? I'm with you, but I have no idea.






                      "Chef" <Chef@discussio ns.microsoft.co mwrote in message
                      news:21B6B10F-FC02-42D8-9FDB-B7DDE4DC2EC9@mi crosoft.com...
                      If I use gmail as smtp server, what the different between port 587 and
                      port
                      465 is?
                      >
                      I just check gmail online help, it recommend that we use port 465. Why?
                      Waht
                      is the reason you used port 587?
                      >
                      Thanks in advance!
                      >
                      "sloan" wrote:
                      >

                      I have downloadable examples here:

                      2/8/2006
                      Smarter Email/Smtp setup with DotNet Configuration Sections (1.1 and
                      2.0)



                      "Chef" <Chef@discussio ns.microsoft.co mwrote in message
                      news:7A8A6D47-6E48-4767-B7B9-201A75C691DF@mi crosoft.com...
                      I can use outlook2003 to send email,but I cann't use this code below
                      to
                      send
                      email.
                      Please help me to test this code and instruct me how to solve this
                      problem
                      in detail.
                      >
                      >
                      >
                      software environment: VS2005 + XP.-- I have disabled firewall
                      hardware enviornmnet:tel com's modem connects hub,hub connects two
                      computers.?-- I also tried to connect computer to modem directly,but I
                      can
                      surf internet, not send email with code.
                      >
                      =============== ==============
                      System.Net.Mail .SmtpClient client = new SmtpClient();
                      client.Host = "smtp.gmail.com ";
                      client.Port = 465;
                      client.UseDefau ltCredentials = false;
                      client.Credenti als = new System.Net.Netw orkCredential(" uid",
                      "pwd");
                      //I also try to use full email address to replace uid. It didn't work.
                      client.Delivery Method = SmtpDeliveryMet hod.Network;
                      >
                      System.Net.Mail .MailMessage message = new
                      MailMessage("ui d@hotmail.com", "uid@hotmail.co m", "Subject",
                      >
                      "Body");
                      message.BodyEnc oding = System.Text.Enc oding.UTF8;
                      message.IsBodyH tml = true;
                      >
                      try
                      {
                      client.Send(mes sage);
                      Response.Write( "Email successfully sent.");
                      }
                      catch (Exception ex)
                      {
                      Response.Write( "Send Email Failed." + ex.ToString()); ;
                      }
                      ===============

                      Comment

                      • sloan

                        #12
                        Re: How to send email with vs2005?


                        Not really, unless I was sitting next to you (or at least on your network).

                        I've found smtp email sending is experimentation sometimes.

                        Thus why I built the "smarter email configuration" model.

                        Because I'd get different behavior

                        at work
                        at home
                        using dialup somewhere.

                        Sometimes its an art, not a science.




                        "Chef" <Chef@discussio ns.microsoft.co mwrote in message
                        news:31199C3A-DA3C-4BF7-AF21-56C4A1560958@mi crosoft.com...
                        Thank you very much.
                        >
                        Your code is really helpfull. It worked with port 587, not 465 on my pc.
                        One
                        more thing, could you tell me what the problem is with my code?
                        >
                        >
                        "sloan" wrote:
                        >

                        I have downloadable examples here:

                        2/8/2006
                        Smarter Email/Smtp setup with DotNet Configuration Sections (1.1 and
                        2.0)



                        "Chef" <Chef@discussio ns.microsoft.co mwrote in message
                        news:7A8A6D47-6E48-4767-B7B9-201A75C691DF@mi crosoft.com...
                        I can use outlook2003 to send email,but I cann't use this code below
                        to
                        send
                        email.
                        Please help me to test this code and instruct me how to solve this
                        problem
                        in detail.
                        >
                        >
                        >
                        software environment: VS2005 + XP.-- I have disabled firewall
                        hardware enviornmnet:tel com's modem connects hub,hub connects two
                        computers.?-- I also tried to connect computer to modem directly,but I
                        can
                        surf internet, not send email with code.
                        >
                        =============== ==============
                        System.Net.Mail .SmtpClient client = new SmtpClient();
                        client.Host = "smtp.gmail.com ";
                        client.Port = 465;
                        client.UseDefau ltCredentials = false;
                        client.Credenti als = new System.Net.Netw orkCredential(" uid",
                        "pwd");
                        //I also try to use full email address to replace uid. It didn't work.
                        client.Delivery Method = SmtpDeliveryMet hod.Network;
                        >
                        System.Net.Mail .MailMessage message = new
                        MailMessage("ui d@hotmail.com", "uid@hotmail.co m", "Subject",
                        >
                        "Body");
                        message.BodyEnc oding = System.Text.Enc oding.UTF8;
                        message.IsBodyH tml = true;
                        >
                        try
                        {
                        client.Send(mes sage);
                        Response.Write( "Email successfully sent.");
                        }
                        catch (Exception ex)
                        {
                        Response.Write( "Send Email Failed." + ex.ToString()); ;
                        }
                        ===============

                        Comment

                        • =?Utf-8?B?Q2hlZg==?=

                          #13
                          Re: How to send email with vs2005?

                          Thank you very much and have a nice day!



                          "sloan" wrote:
                          >
                          I have no idea.
                          >
                          Experimentation showed that for 1.1 .. one of those ports worked.
                          and for 2.0, only the other one worked.
                          ????
                          >
                          Huh? I'm with you, but I have no idea.
                          >
                          >
                          >
                          >
                          >
                          >
                          "Chef" <Chef@discussio ns.microsoft.co mwrote in message
                          news:21B6B10F-FC02-42D8-9FDB-B7DDE4DC2EC9@mi crosoft.com...
                          If I use gmail as smtp server, what the different between port 587 and
                          port
                          465 is?

                          I just check gmail online help, it recommend that we use port 465. Why?
                          Waht
                          is the reason you used port 587?

                          Thanks in advance!

                          "sloan" wrote:
                          >
                          I have downloadable examples here:
                          >
                          2/8/2006
                          Smarter Email/Smtp setup with DotNet Configuration Sections (1.1 and
                          2.0)

                          >
                          >
                          "Chef" <Chef@discussio ns.microsoft.co mwrote in message
                          news:7A8A6D47-6E48-4767-B7B9-201A75C691DF@mi crosoft.com...
                          I can use outlook2003 to send email,but I cann't use this code below
                          to
                          send
                          email.
                          Please help me to test this code and instruct me how to solve this
                          problem
                          in detail.



                          software environment: VS2005 + XP.-- I have disabled firewall
                          hardware enviornmnet:tel com's modem connects hub,hub connects two
                          computers.?-- I also tried to connect computer to modem directly,but I
                          can
                          surf internet, not send email with code.

                          =============== ==============
                          System.Net.Mail .SmtpClient client = new SmtpClient();
                          client.Host = "smtp.gmail.com ";
                          client.Port = 465;
                          client.UseDefau ltCredentials = false;
                          client.Credenti als = new System.Net.Netw orkCredential(" uid",
                          "pwd");
                          //I also try to use full email address to replace uid. It didn't work.
                          client.Delivery Method = SmtpDeliveryMet hod.Network;

                          System.Net.Mail .MailMessage message = new
                          MailMessage("ui d@hotmail.com", "uid@hotmail.co m", "Subject",

                          "Body");
                          message.BodyEnc oding = System.Text.Enc oding.UTF8;
                          message.IsBodyH tml = true;

                          try
                          {
                          client.Send(mes sage);
                          Response.Write( "Email successfully sent.");
                          }
                          catch (Exception ex)
                          {
                          Response.Write( "Send Email Failed." + ex.ToString()); ;
                          }
                          ===============
                          >
                          >
                          >
                          >
                          >
                          >

                          Comment

                          • Juan T. Llibre

                            #14
                            Re: How to send email with vs2005?

                            re:
                            !Experimentatio n showed that for 1.1 .. one of those ports worked.
                            !and for 2.0, only the other one worked.

                            Check for code differences.

                            The port used depends on your ISP's ( Gmail, in this case ) server's settings,
                            and not on any code you write. The port is determined by your ISP, not by your code.



                            Juan T. Llibre, asp.net MVP
                            asp.net faq : http://asp.net.do/faq/
                            foros de asp.net, en español : http://asp.net.do/foros/
                            =============== =============== =====
                            "sloan" <sloan@ipass.ne twrote in message news:uTSFifzZHH A.5056@TK2MSFTN GP03.phx.gbl...
                            >
                            I have no idea.
                            >
                            Experimentation showed that for 1.1 .. one of those ports worked.
                            and for 2.0, only the other one worked.
                            ????
                            >
                            Huh? I'm with you, but I have no idea.
                            >
                            >
                            >
                            >
                            >
                            >
                            "Chef" <Chef@discussio ns.microsoft.co mwrote in message
                            news:21B6B10F-FC02-42D8-9FDB-B7DDE4DC2EC9@mi crosoft.com...
                            >If I use gmail as smtp server, what the different between port 587 and
                            port
                            >465 is?
                            >>
                            >I just check gmail online help, it recommend that we use port 465. Why?
                            Waht
                            >is the reason you used port 587?
                            >>
                            >Thanks in advance!
                            >>
                            >"sloan" wrote:
                            >>
                            >
                            I have downloadable examples here:
                            >
                            2/8/2006
                            Smarter Email/Smtp setup with DotNet Configuration Sections (1.1 and
                            2.0)

                            >
                            >
                            "Chef" <Chef@discussio ns.microsoft.co mwrote in message
                            news:7A8A6D47-6E48-4767-B7B9-201A75C691DF@mi crosoft.com...
                            I can use outlook2003 to send email,but I cann't use this code below
                            to
                            send
                            email.
                            Please help me to test this code and instruct me how to solve this
                            problem
                            in detail.
                            >
                            >
                            >
                            software environment: VS2005 + XP.-- I have disabled firewall
                            hardware enviornmnet:tel com's modem connects hub,hub connects two
                            computers.?-- I also tried to connect computer to modem directly,but I
                            can
                            surf internet, not send email with code.
                            >
                            =============== ==============
                            System.Net.Mail .SmtpClient client = new SmtpClient();
                            client.Host = "smtp.gmail.com ";
                            client.Port = 465;
                            client.UseDefau ltCredentials = false;
                            client.Credenti als = new System.Net.Netw orkCredential(" uid",
                            "pwd");
                            //I also try to use full email address to replace uid. It didn't work.
                            client.Delivery Method = SmtpDeliveryMet hod.Network;
                            >
                            System.Net.Mail .MailMessage message = new
                            MailMessage("ui d@hotmail.com", "uid@hotmail.co m", "Subject",
                            >
                            "Body");
                            message.BodyEnc oding = System.Text.Enc oding.UTF8;
                            message.IsBodyH tml = true;
                            >
                            try
                            {
                            client.Send(mes sage);
                            Response.Write( "Email successfully sent.");
                            }
                            catch (Exception ex)
                            {
                            Response.Write( "Send Email Failed." + ex.ToString()); ;
                            }
                            ===============
                            >
                            >
                            >
                            >
                            >

                            Comment

                            • sloan

                              #15
                              Re: How to send email with vs2005?

                              Juan


                              I agree with you.. except for the gmail smtp server.

                              1.1 framework likes port 465
                              2.0 Framework, my tests show that gmail likes port 587

                              I can't explain only, I can only say that was how it played out.





                              "Juan T. Llibre" <nomailreplies@ nowhere.comwrot e in message
                              news:%23l7jvmzZ HHA.2076@TK2MSF TNGP04.phx.gbl. ..
                              re:
                              !Experimentatio n showed that for 1.1 .. one of those ports worked.
                              !and for 2.0, only the other one worked.
                              >
                              Check for code differences.
                              >
                              The port used depends on your ISP's ( Gmail, in this case ) server's
                              settings,
                              and not on any code you write. The port is determined by your ISP, not by
                              your code.
                              >
                              >
                              >
                              Juan T. Llibre, asp.net MVP
                              asp.net faq : http://asp.net.do/faq/
                              foros de asp.net, en español : http://asp.net.do/foros/
                              =============== =============== =====
                              "sloan" <sloan@ipass.ne twrote in message
                              news:uTSFifzZHH A.5056@TK2MSFTN GP03.phx.gbl...

                              I have no idea.

                              Experimentation showed that for 1.1 .. one of those ports worked.
                              and for 2.0, only the other one worked.
                              ????

                              Huh? I'm with you, but I have no idea.






                              "Chef" <Chef@discussio ns.microsoft.co mwrote in message
                              news:21B6B10F-FC02-42D8-9FDB-B7DDE4DC2EC9@mi crosoft.com...
                              If I use gmail as smtp server, what the different between port 587 and
                              port
                              465 is?
                              >
                              I just check gmail online help, it recommend that we use port 465. Why?
                              Waht
                              is the reason you used port 587?
                              >
                              Thanks in advance!
                              >
                              "sloan" wrote:
                              >

                              I have downloadable examples here:

                              2/8/2006
                              Smarter Email/Smtp setup with DotNet Configuration Sections (1.1 and
                              2.0)



                              "Chef" <Chef@discussio ns.microsoft.co mwrote in message
                              news:7A8A6D47-6E48-4767-B7B9-201A75C691DF@mi crosoft.com...
                              I can use outlook2003 to send email,but I cann't use this code
                              below
                              to
                              send
                              email.
                              Please help me to test this code and instruct me how to solve this
                              problem
                              in detail.
                              >
                              >
                              >
                              software environment: VS2005 + XP.-- I have disabled firewall
                              hardware enviornmnet:tel com's modem connects hub,hub connects two
                              computers.?-- I also tried to connect computer to modem
                              directly,but I
                              can
                              surf internet, not send email with code.
                              >
                              =============== ==============
                              System.Net.Mail .SmtpClient client = new SmtpClient();
                              client.Host = "smtp.gmail.com ";
                              client.Port = 465;
                              client.UseDefau ltCredentials = false;
                              client.Credenti als = new
                              System.Net.Netw orkCredential(" uid",
                              "pwd");
                              //I also try to use full email address to replace uid. It didn't
                              work.
                              client.Delivery Method = SmtpDeliveryMet hod.Network;
                              >
                              System.Net.Mail .MailMessage message = new
                              MailMessage("ui d@hotmail.com", "uid@hotmail.co m", "Subject",
                              >
                              "Body");
                              message.BodyEnc oding = System.Text.Enc oding.UTF8;
                              message.IsBodyH tml = true;
                              >
                              try
                              {
                              client.Send(mes sage);
                              Response.Write( "Email successfully sent.");
                              }
                              catch (Exception ex)
                              {
                              Response.Write( "Send Email Failed." + ex.ToString()); ;
                              }
                              ===============

                              >
                              >

                              Comment

                              Working...