Link to home
Start Free TrialLog in
Avatar of tommyboy115
tommyboy115Flag for United States of America

asked on

Random Exclamation Points in Email Message sent from VBA

Hello (I'm asking this question under Access now, I had previously asked it under HTML without much result),

I'm sending email messages with vbSendMail through Access & VBA.  Everything works great, however, when the message is really long, totally random exclamation points show up in the text of the message when viewing it as the recipient.  I've seen some solutions for this with PHP users and the use of wordwrapping, but I'm a novice HTML person and not sure how to translate that solution over to something that will work for me.  They referenced that a message can only be so long for transfer over SMTP and must have line breaks.  Here is the code for sending the message.  "eMessage" is a variable containg the message text and is from a Memo field in an Access table.

 poSendMail.Message = "<body background=http://www.e-afa.com/ans/BG.JPG>" _
                    & "<div align=center>" _
                    & "<table border=0 width=652 cellspacing=0 cellpadding=0 id=table1> <tr>" _
                    & "<td><img border=0 src=http://www.e-afa.com/ans/HEADER_AFA_BULLETIN.JPG width=652 height=236></td>" _
                    & "</tr> <tr>" _
                    & "<td height=508 background=http://www.e-afa.com/ans/BODY.JPG valign=top> <div align=center>" _
                    & "<table border=0 width=583 cellspacing=0 cellpadding=0 id=table2 height=300> <tr>" _
                    & "<td valign=top><font face=Arial size=2> " & eMessage & " </font></p><br>" _
                    & "<p><font face=Arial size=1>Special Note: Attachments to this email, if any, were created with Adobe Acrobat.&nbsp; To view these attachments, you may download the free Acrobat Reader at " _
                    & "<a href=http://www.adobe.com/products/acrobat/readstep2.html>http://www.adobe.com/products/acrobat/readstep2.html</a>.</font></td>" _
                    & "</tr> </table> </div> </td> </tr> <tr>" _
                    & "<td><img border=0 src=http://www.e-afa.com/ans/FOOTER.JPG width=649 height=100></td>" _
                    & "</tr> </table> </div> </body>"

Any thoughts would be appreciated.  Thanks!

Tom
SOLUTION
Avatar of AlexNek
AlexNek

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
Avatar of tommyboy115

ASKER

So in looking at the code I provided, is there a quick fix I can apply to it to get this working correctly?  I'm by no means an HTML expert and I definitely don't want to be.  Any specific ideas to fixing the code above would be appreciated.
SOLUTION
Avatar of Christopher Kile
Christopher Kile
Flag of United States of America image

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
The " _" in my example are just breaking up the line of code and aren't part of the html.  What I posted is from my VBA code.  Here is the solution for PHP, is there an HTML equivalent to this:

#######################################################################################################

I had the problem that when sending "large" emails (at least 1000 characters), the mail function would add exclamation characters "!" into the body of the email.

This was easily fixed by adding a wordwrap to the body of the email. The following function will do this for you:

<?php
function send_mail($myname, $myemail, $contactname, $contactemail, $subject, $message, $bcc) {

   $headers .= "MIME-Version: 1.0\n";
   $headers .= "Content-type: text/html; charset=iso-8859-1\n";
   $headers .= "From: \"".$myname."\" <".$myemail.">\n";
       
   if ($bcc != "")
       $headers .= "Bcc: ".$bcc."\n";    
   $output = $message;                $output = wordwrap($output, 72);
   return(mail("\"".$contactname."\" <".$contactemail.">", $subject, $output, $headers));
}
?>

taken from: http://uk.php.net/manual/en/function.mail.php

################################################################################################


Is there anything like this that can work for my situation, along the lines of a "wordwrap"?

Thanks
ASKER CERTIFIED SOLUTION
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
giltjr,

I scored you the points for the effort, but I came up with my own dumb way of doing it.  While not clean, by randomly inserting carriage returns throughout my text after I typed it up, I get around the line length issue.  When the email client receives the email, it seems to ignore the carriage returns and wrap the text like normal.  I was going over 998 characters.  Thanks for the input.
Sorry, I thought this was another post of mine where only one person was answering me.  I gave points to everyone who participated on this one.  Thanks!