I want to check sending emails locally. I use this code
If DT.Rows.Count > 0 Then
Dim TmpEmail As String = DT.Rows(0).Item("email").ToString
Dim mail As New MailMessage()
Dim SmtpClient As New SmtpClient("webmail.namespace.net")
mail.From = New MailAddress("mymail@mynamespace.net")
mail.[To].Add(TmpEmail)
mail.Subject = " subject" & Subject_EmailType_Max10Char
mail.IsBodyHtml = True
mail.Body = BodyHtml
SmtpClient.Port = 25
SmtpClient.DeliveryMethod = SmtpDeliveryMethod.Network
SmtpClient.UseDefaultCredentials = False
SmtpClient.Credentials = New System.Net.NetworkCredential("mymail@mynamespace.net", "########password")
SmtpClient.EnableSsl = True
SmtpClient.Timeout = 200000
SmtpClient.Send(mail)
when I send email to the same Domain of my network the email send successfully but when I send email to gmail the error MailBox unavailable. The server response was: 5.7.1 Unable to relay
will appear when send email .When I send from my email (from outlook) to outside domain there is not problem.
I use framework 4.5 visual studio 2012.
I google for it and find solution like configured SMTP server but I don't want to install IIS6. I want to check it locally. Any idea?
I also use my gmail as mail.From and for SmtpClient.Credentials
set my gmail and password and set SmtpClient.Port = 587
and Dim SmtpClient As New SmtpClient("smtp.gmail.com")
and send email to gmail account the problem remain the same.The error is Failure sending mail..