Hi all This is my first post. For sending the mail i m using following code:
Sub SendMail()
Dim sr As New StreamReader(Server.MapPath("slammail.htm"))
Dim msgBody As String = sr.ReadToEnd
sr.Close()
msgBody = msgBody.Replace("Account_Username", txtUserName.Text)
msgBody = msgBody.Replace("Account_UserPassword", txtPassword.Text)
msgBody = msgBody.Replace("Account_SlamUrl", txtUserName.Text)
Dim smtpServer As String = "webmail.xxx.com"
Dim userName As String = "
[email protected]"
Dim password As String = "xxx"
Dim cdoBasic As Integer = 1
Dim cdoSendUsingPort As Integer = 2
Dim objMail As New System.Web.Mail.MailMessage
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", smtpServer)
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 25)
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", cdoSendUsingPort)
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", cdoBasic)
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "
[email protected]")
objMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xxx")
'Dim objMail As New MailMessage
objMail.To = txtEmail.Text
objMail.From = """xxx""" & "xxx"""
objMail.Subject = "Welcome to xxx"
objMail.BodyFormat = MailFormat.Html
objMail.Body = msgBody
Try
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(objMail)
Catch ex As Exception
'SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(objMail)
End Try
End Sub
As this method required username password which is not always work when i work for my some client as they are not willing to give his password to me. Can somebody please tell some method of sending authenticate mail without the requirement of password.