SMTP Mail Sending Problem.....?
-
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
-
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 TryHave a nice day dude.
Regards,
Venkatesh Mookkan.
Software Engineer -
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 TryHave a nice day dude.
Regards,
Venkatesh Mookkan.
Software Engineerdear 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...
-
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...
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