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. SMTP Mail Sending Problem.....?

SMTP Mail Sending Problem.....?

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netcomsysadmin
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.
  • F Offline
    F Offline
    fmlove
    wrote on last edited by
    #1

    Can anybody tell me about sending a mail using smtp(ASP.NET & VB.NET). Please tell me about Mail Server Settings and other all necessary settings that is essential for mail sending.............my email : fm_love82@hotmail.com Feroze Ahmed

    Z V 2 Replies Last reply
    0
    • F fmlove

      Can anybody tell me about sending a mail using smtp(ASP.NET & VB.NET). Please tell me about Mail Server Settings and other all necessary settings that is essential for mail sending.............my email : fm_love82@hotmail.com Feroze Ahmed

      Z Offline
      Z Offline
      zahra yousefi
      wrote on last edited by
      #2

      Hi you can use following code: Dim objMail As New System.Net.Mail.MailMessage Dim smtpClient As New System.Net.Mail.SmtpClient smtpClient.Host = "192.168.12.5" 'smtp.gmail.com or a valid smtp server smtpClient.Port = 25 '465 Dim HTML As String HTML = "sample" Dim fromAddress As New System.Net.Mail.MailAddress("SenderEmail") objMail.To.Add("ReceiverEmail") objMail.From = fromAddress objMail.CC.Add("CC Email") objMail.Subject = "Test" objMail.IsBodyHtml = True objMail.BodyEncoding = System.Text.Encoding.UTF8 objMail.Priority = Mail.MailPriority.High objMail.Body = HTML smtpClient.Send(objMail) Hope it can help,

      zahra yousefi yousefi105@yahoo.com

      1 Reply Last reply
      0
      • F fmlove

        Can anybody tell me about sending a mail using smtp(ASP.NET & VB.NET). Please tell me about Mail Server Settings and other all necessary settings that is essential for mail sending.............my email : fm_love82@hotmail.com Feroze Ahmed

        V Offline
        V Offline
        Venkatesh Mookkan
        wrote on last edited by
        #3

        Try this man. This example is tested in .NET 2.0 framework.

        Dim SMTP As New Net.Mail.SmtpClient(ConfigurationManager.AppSettings("SMTP_ServerName"))
        Dim Message As New Net.Mail.MailMessage
        Try
        SMTP.Credentials = New Net.NetworkCredential(ConfigurationManager.AppSettings("SMTP_Username"), ConfigurationManager.AppSettings("SMTP_Password"))
        Message.To.Add("tosomeone@someserver.com")
        Message.From = New Net.Mail.MailAddress("itsme@myserver.com", "itsme")
        Message.Sender = New Net.Mail.MailAddress("itsme@myserver.com", "itsme")
        Message.Body = "This is a sample mail to test the SMTP Service"
        SMTP.Send(Message)
        Catch ex As Exception
        Throw ex
        End Try

        Have a nice day dude.

        Regards,
        Venkatesh Mookkan.
        Software Engineer

        F 1 Reply Last reply
        0
        • V Venkatesh Mookkan

          Try this man. This example is tested in .NET 2.0 framework.

          Dim SMTP As New Net.Mail.SmtpClient(ConfigurationManager.AppSettings("SMTP_ServerName"))
          Dim Message As New Net.Mail.MailMessage
          Try
          SMTP.Credentials = New Net.NetworkCredential(ConfigurationManager.AppSettings("SMTP_Username"), ConfigurationManager.AppSettings("SMTP_Password"))
          Message.To.Add("tosomeone@someserver.com")
          Message.From = New Net.Mail.MailAddress("itsme@myserver.com", "itsme")
          Message.Sender = New Net.Mail.MailAddress("itsme@myserver.com", "itsme")
          Message.Body = "This is a sample mail to test the SMTP Service"
          SMTP.Send(Message)
          Catch ex As Exception
          Throw ex
          End Try

          Have a nice day dude.

          Regards,
          Venkatesh Mookkan.
          Software Engineer

          F Offline
          F Offline
          fmlove
          wrote on last edited by
          #4

          dear Venkatesh Mookkan thanks for help. But dear actually i don't know what is SMTP_ServerName and SMTP_Uername please help me... My Code is ..... Private mMailServer As String Private mTo As String Private mFrom As String Private mMsg As String Private mSubject As String Private mCC As String Private mPort As Integer Dim strMsg As String strMsg = "Thank you for Feedback" mTo = Trim(ferozeahmed1@hotmail.com) mFrom = Trim("fm_love82@hotmail.com") mSubject = Trim("Thanks") mMsg = Trim(strMsg) mMailServer = "controll-dev-1" ' My Computer Name mPort = 25 mCC = Trim("letus52@yahoo.com") Try Dim message As New MailMessage(mFrom, mTo, mSubject, mMsg) If mCC <> "" Or mCC <> String.Empty Then Dim strCC() As String = Split(mCC, ";") Dim strThisCC As String For Each strThisCC In strCC message.CC.Add(Trim(strThisCC)) Next End If Dim mySmtpClient As New SmtpClient(mMailServer, mPort) mySmtpClient.UseDefaultCredentials = True mySmtpClient.Send(message) MessageBox("The mail message has been sent to " & message.To.ToString()) 'Response.Redirect("Default_retail.aspx") Catch ex As FormatException MessageBox("Format Exception: " & ex.Message) Catch ex As SmtpException MessageBox("SMTP Exception: " & ex.Message) Catch ex As Exception MessageBox("General Exception: " & ex.Message) End Try Dear when i click on send button "Failure Sending Mail" error occur. please tell me whats wrong with this code and tell me what can i write mailserver...

          V 1 Reply Last reply
          0
          • F fmlove

            dear Venkatesh Mookkan thanks for help. But dear actually i don't know what is SMTP_ServerName and SMTP_Uername please help me... My Code is ..... Private mMailServer As String Private mTo As String Private mFrom As String Private mMsg As String Private mSubject As String Private mCC As String Private mPort As Integer Dim strMsg As String strMsg = "Thank you for Feedback" mTo = Trim(ferozeahmed1@hotmail.com) mFrom = Trim("fm_love82@hotmail.com") mSubject = Trim("Thanks") mMsg = Trim(strMsg) mMailServer = "controll-dev-1" ' My Computer Name mPort = 25 mCC = Trim("letus52@yahoo.com") Try Dim message As New MailMessage(mFrom, mTo, mSubject, mMsg) If mCC <> "" Or mCC <> String.Empty Then Dim strCC() As String = Split(mCC, ";") Dim strThisCC As String For Each strThisCC In strCC message.CC.Add(Trim(strThisCC)) Next End If Dim mySmtpClient As New SmtpClient(mMailServer, mPort) mySmtpClient.UseDefaultCredentials = True mySmtpClient.Send(message) MessageBox("The mail message has been sent to " & message.To.ToString()) 'Response.Redirect("Default_retail.aspx") Catch ex As FormatException MessageBox("Format Exception: " & ex.Message) Catch ex As SmtpException MessageBox("SMTP Exception: " & ex.Message) Catch ex As Exception MessageBox("General Exception: " & ex.Message) End Try Dear when i click on send button "Failure Sending Mail" error occur. please tell me whats wrong with this code and tell me what can i write mailserver...

            V Offline
            V Offline
            Venkatesh Mookkan
            wrote on last edited by
            #5

            Without SMTP Mail Server, we can't send a mail. So, Every Server in a network might have a Mail Server. Please contact your System Administrator get the Mail Server name....

            Regards, Venkatesh Mookkan. Software Engineer, India

            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