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
Apurba RanjanRank #4,352 · 349 reputationPosted Jul 22, 2016, 2:24 AM EDT
Mark TaborRank #914 · 2.3K reputationPosted Jul 22, 2016, 2:27 AM EDT
VenkatRank #1,497 · 1.1K reputationPosted Jul 22, 2016, 6:56 PM EDT
Mark TaborRank #914 · 2.3K reputationPosted Jul 22, 2016, 8:15 PM EDT
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.
VenkatRank #1,497 · 1.1K reputationPosted Jul 22, 2016, 8:53 PM EDT
Mark TaborRank #914 · 2.3K reputationPosted Jul 22, 2016, 10:38 PM EDT
Venkatesan Arasappani do not understand what you are saying , do i need to change the code or what?
VenkatRank #1,497 · 1.1K reputationPosted Jul 22, 2016, 10:44 PM EDT
Mark TaborRank #914 · 2.3K reputationPosted Jul 22, 2016, 11:22 PM EDT
Venkatesan Arasappan
Mark TaborRank #914 · 2.3K reputationPosted Jul 23, 2016, 12:06 AM EDT
Mark TaborRank #914 · 2.3K reputationPosted Jul 23, 2016, 12:18 AM EDT
VenkatRank #1,497 · 1.1K reputationPosted Jul 23, 2016, 12:33 AM EDT
Mark TaborRank #914 · 2.3K reputationPosted Jul 24, 2016, 8:49 PM EDT
"delegate'system.Net.Security.RemoteCertificateValidationCallBack' requires an 'AddressOf' expression or lambda expression as the only argument to its constructor."
Mark TaborRank #914 · 2.3K reputationPosted Jul 24, 2016, 9:13 PM EDT
VenkatRank #1,497 · 1.1K reputationPosted Jul 24, 2016, 9:14 PM EDT
Mark TaborRank #914 · 2.3K reputationPosted Jul 24, 2016, 9:39 PM EDT
Mark TaborRank #914 · 2.3K reputationPosted Jul 24, 2016, 9:47 PM EDT
Mark TaborRank #914 · 2.3K reputationPosted Jul 24, 2016, 9:49 PM EDT
" & Environment.NewLine
" & Environment.NewLine
" & "Plan Pakistan RBME Team
" + "" & Environment.NewLine
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Jul 24, 2016, 10:48 PM EDT
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts