colchar1973
asked on
Sending Mail in .Net 2005
Below is the code i have been using to send mail in .Net 2003 for a while now quite successfully. I have upgraded to .Net 2005 and this no longer works. Can anybody help me with the changes that are needed to make this workable in 2005.
Thanks in advance.
Imports System.IO
Imports System.Web.Mail
Function GetEmailBody(ByVal strFileName As String) As String
Dim srTemplate As StreamReader
srTemplate = File.OpenText(Server.MapPa th(strFile Name))
GetEmailBody = srTemplate.ReadToEnd
srTemplate.Close()
End Function
Private Sub SendEmail(ByVal strTo As String, ByVal strBody As String)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
myMessage.BodyFormat = MailFormat.Html
myMessage.From = "admin@domain.com"
myMessage.To = strTo
myMessage.Subject = "email subject"
myMessage.Body = strBody
myMail.SmtpServer = "relay-hosting.secureserve r.net"
myMail.Send(myMessage)
End Sub
Private Sub btnEmail_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEv entArgs) Handles btnEmail.Click
Dim strEmailBody As String = GetEmailBody("email.html")
strEmailBody = strEmailBody.Replace("##Ad dress##", Session("Email"))
SendEmail(Session("Email") , strEmailBody)
End Sub
Thanks in advance.
Imports System.IO
Imports System.Web.Mail
Function GetEmailBody(ByVal strFileName As String) As String
Dim srTemplate As StreamReader
srTemplate = File.OpenText(Server.MapPa
GetEmailBody = srTemplate.ReadToEnd
srTemplate.Close()
End Function
Private Sub SendEmail(ByVal strTo As String, ByVal strBody As String)
Dim myMessage As New MailMessage
Dim myMail As SmtpMail
myMessage.BodyFormat = MailFormat.Html
myMessage.From = "admin@domain.com"
myMessage.To = strTo
myMessage.Subject = "email subject"
myMessage.Body = strBody
myMail.SmtpServer = "relay-hosting.secureserve
myMail.Send(myMessage)
End Sub
Private Sub btnEmail_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEv
Dim strEmailBody As String = GetEmailBody("email.html")
strEmailBody = strEmailBody.Replace("##Ad
SendEmail(Session("Email")
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Colin