• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 697
  • Last Modified:

CDONTS.NewMail:email address string format in "From" property?

Hi Experts:

    I am working on a program which uses CDONTS library to send emails, but I keep getting error message when running it on my desktop.
    Here is the code that runs into error.
    Set objMsg = CreateObject("CDONTS.NewMail")
    objMsg.BodyFormat = 0   ' MIME encoded mail
    objMsg.MailFormat = 0   ' HTML formatted message
    objMsg.To = strTo
    objMsg.Cc = strCc
    objMsg.From = strFrom
    objMsg.Subject = strSubject
    objMsg.Body = strMessage

I traced the program in VB6, The objMsg variable could be successfully created, but when executing the command "objMsg.From = strFrom", the program will jump into error handler, and the value of Err.Description is "Invalid procedure call or argument.

I looked at the strFrom variable and its value is in the format like
"Company Name<emailAddress1@abc.com;emailAddress2@abc.com>".

After hard coding the value to a string like "emailAddress1@abc.com", the routine works but cannot display company name in the From-address. Tthis is not the solution I want, because I believe there should be a way to display company name..

Thank you!
1 Solution
I believe that CDONTS only accepts email addresses in the format of an Email Address.  It cannot recognize the CompanyName data that you are appending to this.   That is why it works when you hard code the string and doesn't when you have the other characters.  
huangs3Author Commented:
I got a solution by testing.
"Company Name<emailAddr@abc.com>" will work, so the solution is to only put one email address between "<>".
Thank you!

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now