Link to home
Start Free TrialLog in
Avatar of StardustMan
StardustMan

asked on

Error using CDO in Access 2003 VBA

I have the following code that sends an e-mail message via CDO from VBA in an Access 2003 .adp.

There are no errors, but all I get is the subject line.  The body is empty.  I have reviewed all of the solutions here and at Microsoft.  I have followed all of the rules and no matter what I do, I simply can't get the body to show up in the e-mail.

Any help?  I'm really frustrated.:

Code Start
...............................................................................................

    Dim iMsg As CDO.Message
    Dim iConf As CDO.Configuration
    Dim Flds As ADODB.Fields
    Dim strText as string
   
    Set iMsg = New CDO.Message
    Set iConf = New CDO.Configuration
   
    Set Flds = iConf.Fields
    Flds(cdoSendUsingMethod) = cdoSendUsingPort
    Flds(cdoSMTPServer) = "mail.natcominc.com"
    Flds(cdoSMTPServerPort) = 6000
    Flds.Update

   'Create strText w/ concatenated string
         
    strtext = me.customer & " repair for customer " & Me.txtMNF &  " was received on " & Date & " and will go out of  
                              warranty in " & Me.txtDaysRemain & " Days. " & vbCrLf & "Please escalate."
    With iMsg
    Set .Configuration = iConf
    .MimeFormatted = False
    .AutoGenerateTextBody = False
    .From = varUser + "@natcominc.com"
    .To = "plexent@natcominc.com"
    .Subject = "Warranty Expiration Notification: " & me.txtCustomer
    .TextBody = strtext
    .Send
    End With

I get the e-mail fine but there is nothing in the body.  What am I doing wrong?

Any help will be greatly appreciated.



Avatar of Markus Fischer
Markus Fischer
Flag of Switzerland image

What does     .AutoGenerateTextBody = False   do?
ASKER CERTIFIED SOLUTION
Avatar of stevbe
stevbe

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the info, Steve.

I think I would play with that option. If -- despite the lack of mime type -- the TextBody did attempt to create html content, you would want to see a text representation of it.
Apart from that, it's clear that strtext cannot be empty, so we know _something_ is sent to the CDO.Message object.

Good Luck
Avatar of StardustMan
StardustMan

ASKER

I will check this option tomorrow when I get into office.  I'm  Pretty sure that I already tested it with a hard-coded string but I will try again.

Will let you know.

Mike
I'm only guessing here, but in old days things were simple. A message had a "body" and that was it. Now the "body" can (and should) have a MIME part, and depending on the message viewer you are using, one or several parts of the body can be hidden. Are there other properties to the CDO.Messsage object? It there one just called .Body?
Good Luck!
I figured it out.  Steve led me on the right trail. What I ended up doing was to dim "strtext" as string.  Then I concatenated the reference with :

strtext = "Customer: " & me.txtCust & vbcrlf"
strtext = strsql & "Model: " & me.txtModel & vbcrlf"
strtext = strsql & "Action: " & me.txtMsg "

.text = strtext