Jump to content

Recommended Posts

  • Developers
Posted

When you look at the posted example, you can see that the way I have coded it is that the Error Description from the CDO object is returned (not a 0 or 1) and that you should test for @error to see if the sendmail was successful.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

  • 1 month later...
Posted

Holy Crap!!! Been trying to send a simple email with OutlookEX UDF for the past 4 hours [Couldn't get it to send when Outlook was not running].

Found this code, poped it in, filled in the variables and WALLA. Done!!

Thanks JOS

-Chad

Posted (edited)
Is somewhere was EDIT: this issue: the problem under discussion:
Why this function sometimes sends $Body text without previously added @CRLF characters?
Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 2 weeks later...
Posted (edited)

hmm... 

I see that too briefly described the problem so I'll try to describe it accurately.

So I use somenthing like that:

Local $sBody = ''
$sBody &= 'Line 1' & @CRLF
$sBody &= 'Line 2' & @CRLF
$sBody &= 'Line 3' & @CRLF
 
When I send an email usually the content of the email looks like this:
Line 1
Line 2
Line 3
but it happens more frequent that email is the content:
Line 1 Line 2 Line 3
 
Wherein the method for preparing the content in these two cases is identical.
 
Question:
What could be the cause ?
Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)
  On 9/16/2013 at 5:34 PM, Chad2 said:

Holy Crap!!! Been trying to send a simple email with OutlookEX UDF for the past 4 hours [Couldn't get it to send when Outlook was not running].

The OutlookEX UDF has a wrapper function to let you send a mail with a single statement: _OL_Wrapper_SendMail.

What was the problem?

Edited by water

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

  On 9/29/2013 at 8:43 PM, mlipok said:

When I send an email usually the content of the email looks like this:

 

Line 1
Line 2
Line 3
but it happens more frequent that email is the content:

Line 1 Line 2 Line 3
Wherein the method for preparing the content in these two cases is identical.

 

Question:

What could be the cause ?

 

 

The function tries to determine if the mail body is HTML or pure text using this line:

If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then

So if you have a "<" and a ">" in your text then its assumed to be HTML. Insert "<BR>" to add a break or "<P>" to add a new paragraph to your body.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
As Spock would say:    It is quite logical.
 
Thanks, and
//_
 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

:)

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)
I think you're right.
As it turned out the contents of an email I sent an SQL query
something like: "select * from abc where xyz <> 0"

 

As I understand it, the use of special characters should help


&lt; &#60; &#x3C; less-than sign <
&gt; &#62; &#x3E; greater-than sign  >
 
$sBody = StringReplace($sBody, '<','&lt;')
$sBody = StringReplace($sBody, '>','&gt;')
Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

  On 9/29/2013 at 9:44 PM, mlipok said:
$sBody = StringReplace($sBody, '<','&lt;')
$sBody = StringReplace($sBody, '>','&gt;')

This won't work. If the function doesn't determine a "<" and a ">" character in the body then the body will be sent as plain text.

Then "&gt;" won't be shown as ">" but as "&gt;".

So: When you use HTML in your body make sure that the function interprets the body as HTML.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

so, how to send a "<" and a ">" character in the body when I want to send them as plain text ?

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Rewrite the function by adding a new parameter that tells the function whether to use HTML or Text mode, then change the section of code where it does the StringInStr to use this new parameter instead. 

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted (edited)
  On 9/29/2013 at 11:18 PM, BrewManNH said:

Rewrite the function by adding a new parameter that tells the function whether to use HTML or Text mode, then change the section of code where it does the StringInStr to use this new parameter instead. 

 

you mean, this

If StringInStr($as_Body, "<") And StringInStr($as_Body, ">") Then
    $objEmail.HTMLBody = $as_Body
    $objEmail.HTMLBodyPart.Charset = "utf-8"
    $objEmail.HTMLBodyPart.ContentTransferEncoding = "quoted-printable"
Else
    $objEmail.Textbody = $as_Body & @CRLF
    $objEmail.TextBodyPart.Charset = "utf-8"
    $objEmail.TextBodyPart.ContentTransferEncoding = "quoted-printable"
EndIf

I change this to:

If StringInStr($as_Body, "<!DOCTYPE html>") Then
....
..
EndIf

and it works 

Thanks @BrewManNH and @water

 

EDIT:

ps.

I thought that adding the parameter is superfluous and did so as you can see above.

Edited by mlipok

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted
  On 9/29/2013 at 8:50 PM, water said:

The OutlookEX UDF has a wrapper function to let you send a mail with a single statement: _OL_Wrapper_SendMail.

What was the problem?

 

Responded on your OutlookEX General help and support thread.

Posted

Answered there.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Jos,

I have been working to get XProTec working for days now, and I got it working on my system fine. The first friend I had test my program started getting the FATAL COM Error after he entered his email. Well, perusing thru the multitude of pages on the XProTec forum I found the issue had to do with the mailer functions in it, and Valuater kept pointing people to this topic to get them figured out. So here is my issue.

Program works FINE from my computer, had no com errors at all. I have since passed it to 2 friends to test, and they both get that COM Error. My code is below, but I am sure you are familiar with it. My question is, can you help me add an error check to tell me exactly WHAT COM error it is getting, or short of that tell me what is wrong if you see something wrong? Do I need any specific includes for this functions to work?

Thanks Jos!

Func mEmailer($e_Sender, $e_Recipient, $e_CcAddress, $e_Subject, $e_Text)
    ; Info for this function by JdeB = http://www.autoitscript.com/forum/index.php?s=&showtopic=23860&view=findpost&p=166575
    $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
    $objMessage = ObjCreate("CDO.Message")
    With $objMessage
        .Subject = $e_Subject
        .Sender = $e_Sender
        .From = $e_Sender
        .To = $e_Recipient
        .Cc = $e_CcAddress
        .TextBody = $e_Text
    EndWith
    With $objMessage.Configuration.Fields
        .Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $smtpserver
        .Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
        .Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $sendusername
        .Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $sendpassword
        .Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        .Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
        .Update
    EndWith
    $objMessage.Send
    If @error Then MyErrFunc()
    $oMyError = ""
    $objMessage = ""
EndFunc   ;==>mEmailer
Func Qbox($t1, $L1)
    $Qbox = InputBox($t1, $L1, "", "", 300, 150)
    If @error = 1 Then Exit
    Return $Qbox
EndFunc   ;==>Qbox
Func mError($sText, $ret = 0, $iFatal = 0)
    MsgBox(48 + 4096 + 262144, "*XProTec*", $sText & " #" & $ret & "   ")
    If $iFatal Then Exit
EndFunc   ;==>mError
Func MyErrFunc()
    MsgBox(262209, "COM / Internal Error", "This Program has been interupted by a Fatal COM Error      ")
    Exit
EndFunc   ;==>MyErrFunc

The MyErrFunc is the error code popping up, which is the only reason I included the extra functions, just to get to it.

My variables, defined at the top of the program are:

#include-once

Global $smtpserver = "smtpout.secureserver.net"
Global $sendusername = "Admin@CraftARR.com"
Global $sendpassword = "*******" ;changed for privacy

This is a GoDaddy hosted email account, and like I said the program works FINE on my machine, and I get emails. However friends get the errors. All 3 of us are using windows 7 btw.

Thanks for any assistance you can provide!

Posted

A COM error handler can provide much more information about the error that occurred. Check the help file for the example in ObjEvent.

The mailing function depends on CDO. The newest versions of Windows don't come with CDO installed. This might cause the problem.

So we need more information about the systems you run your script on and more information about the COM error.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 10/8/2013 at 9:01 PM, water said:

A COM error handler can provide much more information about the error that occurred. Check the help file for the example in ObjEvent.

The mailing function depends on CDO. The newest versions of Windows don't come with CDO installed. This might cause the problem.

So we need more information about the systems you run your script on and more information about the COM error.

 

Looking at my error function can you tell me how to find out what error code it is? I'm not advanced enough to understand the example on the ObjEvent help page. It looks like the @Error holds tha error value? So I can just add that variable to my msgbox?

Posted

Also, if they DON'T have CDO, is there a way around that? My goal is to make this program usable by a large number of people, but not to the extent they have to install annoying programs like outlook express and the like.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...