I am trying to send an email from gmail account to another domain account which i have purchased , i have two methods one methods is working fine but the other is not giving any exception and not sending any email check these two methods the first one works fine
1-
Private Sub SendEmail()
GetUserIDEmail(Session("LoggedInUserId"))
Dim Mail As New MailMessage
Try
Mail.IsBodyHtml = True
Dim MailText As String = Nothing
'Dim attachment As System.Net.Mail.Attachment
Mail.Subject = " Report Submitted By : " & Session("LoggedInUserFullName") & " " & "User Type :" & GetUserTypeName(CInt(Session("UserTypes")))
MailText = MailText + "" & "Dear User, " & "
" & Environment.NewLine
" & Environment.NewLine
MailText = MailText + "" + " " & "we are glad to inform you that your records has accepted." & "
""
" + AcceptComments & """ " + Environment.NewLine
""
" + AcceptComments & """ " + Environment.NewLine
MailText = MailText + "
" & " Regards," & " " & "
" & "Plan Pakistan RBME TEAM" + "" & vbCrLf
" & " Regards," & " " & "
" & "Plan Pakistan RBME TEAM" + "" & vbCrLf
Mail.IsBodyHtml = True
Mail.Body = MailText
Dim files As List(Of HttpPostedFile) = DirectCast(Cache(Me.Key), List(Of HttpPostedFile))
For Each file As HttpPostedFile In files
Mail.Attachments.Add(New Attachment(file.InputStream, Path.GetFileName(file.FileName), file.ContentType))
Next
Mail.From = New MailAddress("[email protected]")
Dim SMTP As New SmtpClient("smtp.gmail.com")
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential("[email protected]", "forgot123")
SMTP.Port = 587
SMTP.Send(Mail)
Catch ex As Exception
ex.Message.ToString()
End Try
End Sub
-----------------------------------------------------------------------
2-This one is not working what is the reason
2-This one is not working what is the reason
Private Sub SendHtmlFormattedEmail(ByVal recepientEmail As String, ByVal subject As String, ByVal body As String)
Dim Mail As New MailMessage
Mail.From = New MailAddress("[email protected]")
Mail.Subject = subject
Mail.Body = body
Mail.IsBodyHtml = True
Mail.To.Add("[email protected]")
Mail.From = New MailAddress("[email protected]")
Dim SMTP As New SmtpClient("smtp.gmail.com")
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential("[email protected]", "forgot123")
SMTP.Port = 587
SMTP.Send(Mail)
End Sub
this second method works fine for gmail but not for my domain email address which i have purchased
Bikesh SrivastavaPosted Jul 25, 2016, 2:48 AM
Mark TaborPosted Jul 25, 2016, 1:49 AM
" & Environment.NewLine
" & Environment.NewLine
" & "Plan Pakistan RBME Team
" + "" & Environment.NewLine
Mark TaborPosted Jul 25, 2016, 1:47 AM
Mark TaborPosted Jul 25, 2016, 1:39 AM
VenkatPosted Jul 25, 2016, 1:14 AM
Mark TaborPosted Jul 25, 2016, 1:13 AM
Mark TaborPosted Jul 25, 2016, 12:49 AM
"delegate'system.Net.Security.RemoteCertificateValidationCallBack' requires an 'AddressOf' expression or lambda expression as the only argument to its constructor."
VenkatPosted Jul 23, 2016, 4:33 AM
Mark TaborPosted Jul 23, 2016, 4:18 AM
Mark TaborPosted Jul 23, 2016, 4:06 AM
Mark TaborPosted Jul 23, 2016, 3:22 AM
Venkatesan Arasappan
VenkatPosted Jul 23, 2016, 2:44 AM
Mark TaborPosted Jul 23, 2016, 2:38 AM
Venkatesan Arasappani do not understand what you are saying , do i need to change the code or what?
VenkatPosted Jul 23, 2016, 12:53 AM
Mark TaborPosted Jul 23, 2016, 12:15 AM
Venkatesan Arasappanthanks for your response , I have shared two methods the first is working fine with my domain email address { i am using gmail to send an email to my domain email address like [email protected]} the first method send the email correctly , weather the second method is not sending email to my domain email address it is sending email to any other email address but not my domain email address , i do not know why it is so.
VenkatPosted Jul 22, 2016, 10:56 PM
Mark TaborPosted Jul 22, 2016, 6:27 AM
Apurba RanjanPosted Jul 22, 2016, 6:24 AM