Jump to content

iNetMail and Spécial Chars


 Share

Recommended Posts

Hi,

A little problem for my notification script.

When I use this part of script and run it, my generated e-mail does not accept special chars like à ê etc...

Do you have any idea on how to do ?

Regards.

Func _Mail()
$SD = $TICKETSD
$Address = $MAIL
$Subject = "Votre ticket n° " & $SD & " - Demande de Prêt de PC Portable"
$Body = "Bonjour," & @CRLF & @CRLF & _
"Votre demande de prêt de pc portable a bien été prise en compte." & @CRLF & @CRLF & _
"Vous pouvez le retirer dès le " & $DU0 & " à l’accueil du bâtiment ." & @CRLF & @CRLF & _
"Nous attendons son retour pour le " & $AU0 & "." & @CRLF & @CRLF & _
"Cordialement."
_INetMail($address, $subject, $body)
EndFunc
Edited by YoannMorl
Link to comment
Share on other sites

You could generate a HTML mail. What's your mail client?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

You can use the "SentOnBehalfOfName" property. The wiki describes how to do.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I don't understand how the EX UDF works. Don't understand what is Item ID and how to use it.

Item ID is stored in $oItem ?

Cause i have 3 accounts on my outlook.

2 generic account and 1 personnal.

I'd like to send a mail with 1 of the genreic account that is not set to default.

Edited by YoannMorl
Link to comment
Share on other sites

Correct.

You create a mail item by calling _OL_ItemCreate. The function returns the object of the created item. You then pass this "ID" to all other functions because they need to know which object to process.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

[edit] are the special characters converted to question marks?

did you try converting to UTF? I think Autoit sends strings in unicode by default.

Try something like this before sending your data (this one converts to UTF16):

_INetMail($address, $subject, BinaryToString(StringToBinary($body, 2), 2))

maybe try to convert to UTF8 too if it doesn't work

Edited by jmon
Link to comment
Share on other sites

@Water

Ok, i've tried but. I'm not satisfied.

Cause i'd like the mail show before send it.

I'd like to be able to verify the content of the mail and click on send if it's ok.

I just need to modify my script to have special chars working and to specify from who is sending the mail.

The UDF correct my problem with chars but with the ex and thi wiki example, i have the error that i've not the authorisation to send on behalf of.

@jmon

Yes, chars a replaced by ? or are just simply bypassed

Not working with

_INetMail($address, $subject, BinaryToString(StringToBinary($body, 2), 2))

or

_INetMail($address, $subject, BinaryToString(StringToBinary($body, 4), 4))

Edited by YoannMorl
Link to comment
Share on other sites

If you just want to create the mail and display it before sending use the following code:

#include <OutlookEx.au3>
; Open the connection to Outlook
Global $oOL = _OL_Open()
; Create a mail item and set some properties
Global $oItem = _OL_ItemCreate($oOL, $olMailItem, "*\Outlook-UDF-Test\TargetFolder\Mail", "", _
    "Subject=TestMail", "BodyFormat=" & $olFormatHTML, "HTMLBody=Bodytext in &lt;b>Test&lt;/b>.", "SentOnBehalfOfName=Doe Jane")
; Add a recipient and resolve it
_OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, "Doe John")
; Display the mail
$oItem.Display()

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I've tried it but it returns me an error :

COM Error Encountered in MAIL.AU3
OutlookEx UDF version = 0.9.0
@AutoItVersion = 3.3.8.1
@AutoItX64 = 0
@Compiled = 0
@OSArch = X64
@OSVersion = WIN_7
Scriptline = 1211
NumberHex = 80020009
Number = -2147352567
WinDescription =
Description = Échec de l’opération. Impossible de trouver un objet.
Source = Microsoft Outlook
HelpFile =
HelpContext = 0
LastDllError = 0
========================================================
COM Error Encountered in MAIL.AU3
OutlookEx UDF version = 0.9.0
@AutoItVersion = 3.3.8.1
@AutoItX64 = 0
@Compiled = 0
@OSArch = X64
@OSVersion = WIN_7
Scriptline = 3075
NumberHex = 80020009
Number = -2147352567
WinDescription =
Description = Impossible d'ouvrir l'élément. Recommencez.
Source = Microsoft Outlook
HelpFile =
HelpContext = 0
LastDllError = 0
========================================================
COM Error Encountered in MAIL.AU3
OutlookEx UDF version = 0.9.0
@AutoItVersion = 3.3.8.1
@AutoItX64 = 0
@Compiled = 0
@OSArch = X64
@OSVersion = WIN_7
Scriptline = 18
NumberHex = 000000A9
Number = 169
WinDescription = Variable must be of type 'Object'.
Description = Impossible d'ouvrir l'élément. Recommencez.
Source = Microsoft Outlook
HelpFile =
HelpContext = 0
LastDllError = 0
========================================================
Link to comment
Share on other sites

Can you post the code you use?

My example above has to be modified because at least "*Outlook-UDF-TestTargetFolderMail" doesn't work for you.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Change "*Mail" to "*Drafts" (or whatever the name of your drafts folder is).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Ok it works. Thanks.

Need to verify the language of outlook before to avoid error in folder name.

Another things it's that i don't want to set on every user of this script the ability to send on behalf of for the mailbox i set.

The generic mailbox is mounted in outlook and user can send mail from them.

Is there a way to speciofy wich account to use and not on behalf of ?

Edited by YoannMorl
Link to comment
Share on other sites

If you need a language independant script then have a look at _OL_FolderAccess. There you can specify the type of folder you want to access without the need to specify its name.

$aFolder = _OL_FolderAccess($oOutlook, "", $olFolderDrafts)
; Create a mail item and set some properties
Global $oItem = _OL_ItemCreate($oOL, $olMailItem, $aFolder[1], "", _
"Subject=TestMail", "BodyFormat=" & $olFormatHTML, "HTMLBody=Bodytext in &lt;b>Test&lt;/b>.", "SentOnBehalfOfName=abc xyz")
Edited by Jos
remove name

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Another things it's that i don't want to set on every user of this script the ability to send on behalf of for the mailbox i set.

The generic mailbox is mounted in outlook and user can send mail from them.

Is there a way to speciofy wich account to use and not on behalf of ?

Edited by YoannMorl
Link to comment
Share on other sites

How do you manually specify that you want to send the mail from the generic mailbox?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

You need to set the Originator like this:

; Set the Originator of the mail and resolve it
_OL_ItemRecipientAdd($oOL, $oItem, Default, $olOriginator, "resolveable name of the sender")

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

This will take some time because I need to do some tests.

Will come back as soon as I have a result ...

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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