"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 wouldnt 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.

Code:
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 by a moderator:
Originally posted by jekul79
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 didnt 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.computerhelp.forum/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"
 
try this:

instead of:
SmtpMail.SmtpServer = "127.0.0.1";
or:
SmtpMail.SmtpServer = "localhost";

write:
SmtpMail.SmtpServer.Insert( 0, "127.0.0.1");
OR
SmtpMail.SmtpServer.Insert( 0, "localhost");

enjoy it
webmaster_2x@yahoo.com
 
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
 
Back
Top