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. General Programming
  3. C#
  4. Sending mail in C# with or without smtp

Sending mail in C# with or without smtp

Scheduled Pinned Locked Moved C#
csharp
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
    razanabanu
    wrote on last edited by
    #1

    Hi firends,im working with webform of C#.I would like to send mail with or without smtpserver.please kindly send me the code with explanation.Thank you in advance.

    Hi,Im Razana

    C 1 Reply Last reply
    0
    • R razanabanu

      Hi firends,im working with webform of C#.I would like to send mail with or without smtpserver.please kindly send me the code with explanation.Thank you in advance.

      Hi,Im Razana

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Hey Razana. YOu need to specify what version of C# you're using. But, you'd do better to type it directly into google. There are tons of examples on this on the web. Of course, without a server, you can't send mail, it's not possible.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      R 1 Reply Last reply
      0
      • C Christian Graus

        Hey Razana. YOu need to specify what version of C# you're using. But, you'd do better to type it directly into google. There are tons of examples on this on the web. Of course, without a server, you can't send mail, it's not possible.

        Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

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

        Hi friends this is the error what im receiving in my application. Server Error in '/afxisityro' Application. -------------------------------------------------------------------------------- The transport failed to connect to the server. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServices.COMException: The transport failed to connect to the server. Source Error: Line 35: Line 36: SmtpMail.SmtpServer="afxisi.com"; //your real server goes here Line 37: SmtpMail.Send(mail); Line 38: // Put user code to initialize the page here Line 39: Source File: c:\inetpub\wwwroot\afxisityro\sendmail.aspx.cs Line: 37 These are the code what im using in my web application MailMessage mail=new MailMessage(); mail.From ="rinooza@gmail.com"; mail.To="razanabanu@gmail.com"; mail.Subject ="HI"; mail.Priority =MailPriority.Normal ; mail.BodyFormat =MailFormat.Html ; mail.Body="Hi! "; mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465"); mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "rojabanu.m@afxisi.co.in"); //set your username here mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "8A4904"); //set your password here mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "false"); SmtpMail.SmtpServer="afxisi.com"; //your real server goes here SmtpMail.Send(mail); // Put user code to initialize the page here

        Hi,Im Razana

        C D 2 Replies Last reply
        0
        • R razanabanu

          Hi friends this is the error what im receiving in my application. Server Error in '/afxisityro' Application. -------------------------------------------------------------------------------- The transport failed to connect to the server. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServices.COMException: The transport failed to connect to the server. Source Error: Line 35: Line 36: SmtpMail.SmtpServer="afxisi.com"; //your real server goes here Line 37: SmtpMail.Send(mail); Line 38: // Put user code to initialize the page here Line 39: Source File: c:\inetpub\wwwroot\afxisityro\sendmail.aspx.cs Line: 37 These are the code what im using in my web application MailMessage mail=new MailMessage(); mail.From ="rinooza@gmail.com"; mail.To="razanabanu@gmail.com"; mail.Subject ="HI"; mail.Priority =MailPriority.Normal ; mail.BodyFormat =MailFormat.Html ; mail.Body="Hi! "; mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465"); mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "rojabanu.m@afxisi.co.in"); //set your username here mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "8A4904"); //set your password here mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "false"); SmtpMail.SmtpServer="afxisi.com"; //your real server goes here SmtpMail.Send(mail); // Put user code to initialize the page here

          Hi,Im Razana

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          razanabanu wrote:

          SmtpMail.SmtpServer="afxisi.com"; //your real server goes here

          Gee - did it occur to you to read the comments and put a real mail server in there ? Like I said, you cannot send mail without a server.

          Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          1 Reply Last reply
          0
          • R razanabanu

            Hi friends this is the error what im receiving in my application. Server Error in '/afxisityro' Application. -------------------------------------------------------------------------------- The transport failed to connect to the server. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Runtime.InteropServices.COMException: The transport failed to connect to the server. Source Error: Line 35: Line 36: SmtpMail.SmtpServer="afxisi.com"; //your real server goes here Line 37: SmtpMail.Send(mail); Line 38: // Put user code to initialize the page here Line 39: Source File: c:\inetpub\wwwroot\afxisityro\sendmail.aspx.cs Line: 37 These are the code what im using in my web application MailMessage mail=new MailMessage(); mail.From ="rinooza@gmail.com"; mail.To="razanabanu@gmail.com"; mail.Subject ="HI"; mail.Priority =MailPriority.Normal ; mail.BodyFormat =MailFormat.Html ; mail.Body="Hi! "; mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465"); mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "rojabanu.m@afxisi.co.in"); //set your username here mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "8A4904"); //set your password here mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "false"); SmtpMail.SmtpServer="afxisi.com"; //your real server goes here SmtpMail.Send(mail); // Put user code to initialize the page here

            Hi,Im Razana

            D Offline
            D Offline
            Declan Bright
            wrote on last edited by
            #5

            Have a chat with your mail server administrators to ensure you have the correct mail server name and port. Also check that traffic on this port is not blocked from PCs in your organisation. Where I work, I cannot connect to the SMTP server from my PC, I have to use a development server when I want to test the sending of emails. :^)

            Declan Bright www.declanbright.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