I am having an issue where some email messages are not being sent even though the Macro script says it is. I am using a VBEval>SendEmail string to send out the script constructed email. What I would like to know is how to get the results of that smtp send operation into a log or another email message to myself, so I know if the result of the SMTP was that it did not go thru. Currently the script writes back that everything went fine, although no message was sent. IF I resend the script at a later time, the message does go thru, indecating that there is nothing wrong with the script itself. I looked at the %SMTP_RESULT% command, but I dont think that is working with the VBEval Send Email command. At least it isnt currently. I have it in the script, but it dosent do anything. (I could have it in the wrong place) Any help is appreciated.
thanks. A copy of the script for sending one message is attached.
-Joe
Code: Select all
VBSTART
'Uses Microsoft CDO Message COM class in Win2k,XP & above. See:
'http://msdn.microsoft.com/library/en-us/cdosys/html/_cdosys_imessage_interface.asp
Function SendEmail(toaddr,bccaddr,fromaddr,subject,body,html)
sch = "http://schemas.microsoft.com/cdo/configuration/"
Set cdoConfig = CreateObject("CDO.Configuration")
With cdoConfig.Fields
.Item(sch & "sendusing") = 2 ' cdoSendUsingPort
'change your mail server on the next line
.Item(sch & "smtpserver") = "192.168.1.2"
.update
End With
Set cdoMessage = CreateObject("CDO.Message")
With cdoMessage
Set .Configuration = cdoConfig
.From = fromaddr
.To = toaddr
.Bcc = bccaddr
.Subject = subject
'.AddAttachment "C:\2008_Shutdown_Notice.pdf"
if html = 1 then
.HTMLBody = body
else
.TextBody = body
end if
'you can create html body from a web page:
'.CreateHTMLBody "http://blablabla.com/bla.htm"
'you can add attachments:
'.AddAttachment "<filename>"
'see URL at top for more options
.Send
End With
Set cdoMessage = Nothing
Set cdoConfig = Nothing
End Function
VBEND
Let>body=<html>
Let>body=%body%<body>
Let>Body=%Body%<table><tr><td><img></td>
Let>Body=%Body%<td><img>Company<br>Specialized Wiping Materials<br>Address<br>Phone Fax <br>
Let>Body=%Body%Outside MA </td></tr></table>
Let>body=%body%<Center><b>SALES ORDER ACKNOWLEDGEMENT</b></Center>
Let>body=%body%<p><b>Customer Order ID: </b>
Let>body=%body%125740<br><b>CustomerID: </b>CUSTNAME</P>
Let>Body=%Body%<table><tr><td><b>Sold To</b></td><td><b>ShipTo</b></td></tr><tr><td>CUSTNAME</td><td>
Let>body=%body%Custname</td></tr><tr><td></td><td></td></tr><tr><td>P.O. Box 123</td><td>710 Main Road</td></tr><tr><td>
Let>body=%body%</td><td></td></tr><tr><td>Town, SC 293040000</td><td>Town, SC 29334</td></tr></table><br><hr><br>
Let>Body=%Body%<table><tr><td><b>Print Date </b>9/25/2008 11:36:25 AM</td><td><b>
Let>body=%body%Customer PO# </b>12345</td></tr><tr><td><b>Order Date </b>9/24/2008</td><td>
Let>body=%body%<b>Freight Terms </b>Freight Billed</td></tr><tr><td><b>Ship Via </b>SHIPPER</td><td><b>Terms </b>
Let>body=%body%
Let>body=%body%</td></tr><tr><td><b>INCOTERM </b>FOB ORIGIN FRT COLLECT</td><td><b>Sales Representative </b>HOUSE20</td></tr><tr><td>
Let>body=%body%<b>Desired Ship Date </B>10/24/2008 </td><td></td></tr><tr><td></td><td></td></tr></table><br><hr>
Let>body=%body%<table><tr><td><B>Order Qty</b></td><td><b>Shipped Qty</b></td>
Let>body=%body%<td><b>Balance Qty</b></td><td><b>Part ID With Description</b></td><td><b>UM</b></td>
Let>body=%body%<td><b>Unit Price</b></td><td><b>Ext Price</b></td></tr></table><hr>
Let>body=%body%<table><tr><td>85</td><td>0</td>
Let>body=%body%<td>85</td><td>
Let>body=%body%AMEC0003<br>
Let>body=%body%9X9 300/BAG 12 BAGS/CASE </td><td>CS</td>
Let>body=%body%<td> $999.870</td><td> $9,999.950 </td></tr></table><hr>
Let>body=%body%<p><b>Subtotal: </b> $99999.950</p>
Let>body=%body%<p><b>Tax: </b> $0.00 </p>
Let>body=%body%<p><b>Total: </b> $9999.95 </p>
Let>body=%body%</body></html>
StringReplace>body,","",body
VBEval>SendEmail("[email protected]","[email protected]","[email protected]","Order Acknowledgement for Order ID 125740, your PO Ref: 20663 ","%body%",1),res
Message>Result of SendMail: %SMTP_RESULT%