"Could not access 'CDO.Message' object."?

Is there any way around email address errors like

"The server rejected one or more recipient addresses. The server response was: 553 5.1.3 <brad@>... Hostname required

My problem is that I am trying to send out a bulk email and one badly formed address will cancel the whole bulk send (as the list is formed in the .BCC property). Is there any way to disable or work around this exception without trying to examine the entire email list for invalid addresses?
 
It wouldn't take long to iterate over the blind list and parse each address using a regular expression, this would also hand you the opportunity to audit your address list for invalid entries.

Should your list be on large side you will want to use the stringbuilder class.

Visual Basic:
Imports System.Text.RegularExpressions
Imports System.Web.mail

    Private malformedaddrlist As String

    Sub sendmail()

        Dim blindlist As String = "good.address@somewhere.com;bad.address@@anotherplace.com;man.on@the.moon;top.test@123.123.123.123"
        Dim addr As String

        Dim mMessage As New MailMessage
        With mMessage
            .From = "AutomatedMail"
            For Each addr In Split(blindlist, ";")
                If Regex.IsMatch(addr, "^([\w-]+\.)*?[\w-]+@[\w-]+\.([\w-]+\.)*?[\w]+$") Then
                    .Bcc &= addr & ";"
                Else
                    malformedAddrList &= addr & ";"
                End If
            Next
        End With

        SmtpMail.SmtpServer = "[servername]"
        SmtpMail.Send(mMessage)

    End Sub
 
Last edited:
jekul79 said:
Is there any way around email address errors like

"The server rejected one or more recipient addresses. The server response was: 553 5.1.3 <brad@>... Hostname required

My problem is that I am trying to send out a bulk email and one badly formed address will cancel the whole bulk send (as the list is formed in the .BCC property). Is there any way to disable or work around this exception without trying to examine the entire email list for invalid addresses?

Well, What I would do is before you send an email that has a Bcc, is create the same email for each bcc address. So if you have 500 bcc address, u will create and send 499 duplicate emails. Other than that, you can use the regex solution providied above.
 
update this line to make it work

I also was able to get it to work by doing the following:


<smtpMailObject>.smtpserver.insert(0,"127.0.01")

instead of

<smtpMailObject>.smtpserver = "localhost"

:)
 
Thanks for this hint.

I had basically "opened up the whole world" to allow people to email from my computer.
And it didn't work.

The ".Insert" method fixed it.


SmtpMail.SmtpServer.Insert (0,smtpServer);
//SmtpMail.SmtpServer = smtpServer; // There is an issue with setting the smtpserver directly
//the .Insert method was a fix described at: http://www.xtremedotnettalk.com/t69426.html






h3xd3m0n said:
I was able to fix this problem by using the following code

<smtpMailObject>.smtpserver.insert(0,"server name")

insted of

<smtpMailObject>.smtpserver = "server name"
 
Quick Fix

I resolved this problem by going into the smtp server in exchange, in authentication, and enabled "resolve anonymous e-mail". That allowed be to send! Hope this helps!
 
Could not access 'CDO.Message' object

Barry said:
Ensure that you have correctly formed email addresses. For example:

Dim mMessage As New MailMessage
With mMessage
.From = "Automated Mail"
.To = "you@yourhouse.com"
End With

will result in >> Could not access 'CDO.Message' object.

(InnerException.Message)
The server rejected the sender address. The server response was: 553 malformed address: <Automated Mail>

removing the space, in this instance, from the .From property will resolve the error.

Imports System.Web.mail

Sub sendmail()

Dim mMessage As New MailMessage
With mMessage
.From = "AutomatedMail"
.To = "you@yourhouse.com"
End With

SmtpMail.SmtpServer = "[servername]"
SmtpMail.Send(mailMsg)

End Sub


Note: some email servers will have policy restrictions applied to them to prevent spam, e.g. mail may only be allowed to go external if its origin is safe.

Check your antivirus from block port 25
and allow your ip address to relay on your SMTP server
 
My second experience with &quot;Could not access 'CDO.Message' object.&quot; My second experience with &quot;Could not access 'CDO.Message' object.&quot; The first time I had it problem it was due to the cdo DLLs not on the server. That was serveral months ago. I setup outlook on the server and that fixed that was fixed. On a different server I setup IPsec packet filtering and it caused the the same &quot;Could not access 'CDO.Message' object.&quot; error. Catch the comexception error and it will give you a more descriptive error message than the general httpexception would. To fix this problem the second time all I had to do was unfilter port 25 for SMTP. IT just sucks that the http exception delivers the same &quot;Could not access 'CDO.Message' error message. I think MS just likes to play with us. I know I would. Hope that helps someone &nbsp;
You it is serious?
 
Back
Top