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

Posted on 2009-02-19
Last Modified: 2013-11-25
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<;>".

After hard coding the value to a string like "", 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!
Question by:huangs3
    LVL 14

    Expert Comment

    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.  

    Accepted Solution

    I got a solution by testing.
    "Company Name<>" will work, so the solution is to only put one email address between "<>".
    Thank you!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now