Send Mail Problem

M

Max

hi

I used mailmessage object to send the mail, my smtp server don't
require authentication, when i try to send the mail it shows error.
following is the code to send mail.

Dim mymail As New MailMessage
Dim smtp As SmtpMail
smtp.SmtpServer = "mailhost.gujarat.gov.in"
mymail.To = "(e-mail address removed)"
mymail.From = "mahesh (check mail delivery)"
mymail.Subject = "check mail delivery"
mymail.Body = "hi this is to check mail delivery"

mymail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport",
"25")

mymail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl",
"true")
Try
smtp.Send(mymail)
Label1.Text = "Mail sucessfully deliverd"
Catch ex As Exception
Label1.Text = ex.Message & "<br>" &
ex.GetBaseException.ToString
End Try

here i have add smtpserverport and smtpusessl fields only i have not
added smtpauthenticate.

now when i add smtpauthenticate=0 it shows same error.

if i remove all the fields and olny assign smtp.SmtpServer if through
following error.
Could not access 'CDO.Message' object.
System.Runtime.InteropServices.COMException (0x8004020E): The server
rejected the sender address. The server response was: 501 : domain
string is NULL.

Please Let me know if any one know the solution
 
W

Willy Denoyette [MVP]

| hi
|
| I used mailmessage object to send the mail, my smtp server don't
| require authentication, when i try to send the mail it shows error.
| following is the code to send mail.
|
| Dim mymail As New MailMessage
| Dim smtp As SmtpMail
| smtp.SmtpServer = "mailhost.gujarat.gov.in"
| mymail.To = "(e-mail address removed)"
| mymail.From = "mahesh (check mail delivery)"
| mymail.Subject = "check mail delivery"
| mymail.Body = "hi this is to check mail delivery"
|
|
mymail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport",
| "25")
|
|
mymail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl",
| "true")
| Try
| smtp.Send(mymail)
| Label1.Text = "Mail sucessfully deliverd"
| Catch ex As Exception
| Label1.Text = ex.Message & "<br>" &
| ex.GetBaseException.ToString
| End Try
|
| here i have add smtpserverport and smtpusessl fields only i have not
| added smtpauthenticate.
|
| now when i add smtpauthenticate=0 it shows same error.
|
| if i remove all the fields and olny assign smtp.SmtpServer if through
| following error.
| Could not access 'CDO.Message' object.
| System.Runtime.InteropServices.COMException (0x8004020E): The server
| rejected the sender address. The server response was: 501 : domain
| string is NULL.
|
| Please Let me know if any one know the solution
|


Please post VB related questions to the microsoft.public.dotnet.languages.vb
NG.
Willy.
 
S

Steven Nagy

Try putting a valid email address in: mymail.From
Currently you just have your name.
 
S

sloan

see
http://sholliday.spaces.live.com/ 2/8/2006
for 1.1 and 2.0 downloadable examples.

You probably need a "good" email return address.

However, check the blog, there are different authentication modes.
Esp since you're messnig around with the .Fields.Add , they'll drive you
crazy!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top