Need SMTP Verification when using VBEval>SendEmail Comman

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Joehome
Junior Coder
Posts: 34
Joined: Tue Nov 06, 2007 8:44 pm
Location: New England

Need SMTP Verification when using VBEval>SendEmail Comman

Post by Joehome » Thu Sep 25, 2008 4:14 pm

Hi Folks,
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%
-Joe

Joehome
Junior Coder
Posts: 34
Joined: Tue Nov 06, 2007 8:44 pm
Location: New England

Workarounds

Post by Joehome » Wed Nov 05, 2008 4:16 pm

Does anyone have any ideas for workarounds?
-Joe
-Joe

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Wed Nov 05, 2008 4:42 pm

SMTP_RESULT belongs to SMTPSendMail.

For CDO.Message you probably need to trap errors with On Error Resume Next and look at Err.Number. You'd have to read the docs at Microsoft.

http://msdn.microsoft.com/en-us/library ... G.10).aspx

If you just needed to know if there was an error or not:

Code: Select all

...
    On Error Resume Next
    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

    If Err.Number = 0
      'Success
    Else
     'fail
    Endif
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Joehome
Junior Coder
Posts: 34
Joined: Tue Nov 06, 2007 8:44 pm
Location: New England

ok

Post by Joehome » Wed Nov 05, 2008 4:53 pm

Thanks Marcus,
I will look at that and see if I can make sense or it. thanks for the reply!
-Joe
-Joe

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts