Problem with SMTPMail object...

  • Thread starter Thread starter Paul Mason
  • Start date Start date
P

Paul Mason

Hi folks,

Can someone let me know if there is a more appropriate area for this
question.

The following code used to work when we had our own email server,which has
now been decommissioned. I can't remember how I managed to get hold of the
smtp server name.

Dim objMail As MailMessage

Dim booRet As Boolean

Dim strBody As String




Try



strBody = "Message goes here"



objMail = New MailMessage



objMail.To = Me.Problem.EmailTo

objMail.From = "Helpdesk system"

objMail.Body = strBody

objMail.Subject = "Subject"

objMail.BodyFormat = Web.Mail.MailFormat.Text



SmtpMail.SmtpServer = "my server name goes here"

SmtpMail.Send(objMail)



booRet = True

Catch ex As Exception

strError = "clsJob.SendReportEmail : " & ex.Message

booRet = False

Finally

objMail = Nothing

End Try


When I put in the new server name it pops up with the following error :

clsJob.SendReportEmail : Could not access 'CDO.Message' object.

I managed to dig out a more specific error message :

clsJob.SendReportEmail : System.Web.HttpException: Could not access
'CDO.Message' object. ---> System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. --->
System.Runtime.InteropServices.COMException (0x8004020E): The server
rejected the sender address. The server response was: 501 5.5.4 Invalid
Address

The help for the smtpmail object goes on about making sure port 25 is open.
Is this symptomatic of this?

Finally how can I make sure I've got the correct server name?

Thanks in advance

Cheers...P
 
From looking at the code and response the problem looks like it is the
objMail.From = "Helpdesk system". This needs to be a valid email address
not just a friendly name. The mail server is rejecting this address thus
the "501 5.5.4 Invalid Address" error. Try setting it to a valid email
address. It may have worked with your other mail server because it was less
vigorous with syntax checking.

Trusty Alternative:
http://www.freesmtp.net
 
Dear Bill,

Thank you, thank you, thank you. So obvious and so simple!

Cheers...P
 
Now that you have solved that problem, for all kind of problems that you can
get yet in the future using smtp mail take a look at this great FAQ
http://systemwebmail.com/

--

Carlos J. Quintero

MZ-Tools 4.0: Productivity add-ins for Visual Studio .NET
You can code, design and document much faster.
http://www.mztools.com
 

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

Similar Threads


Back
Top