Sign in to follow this  
Followers 0
YoannMorl

iNetMail and Spécial Chars

22 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



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


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

We are using Outlook.

I've tried with the outlook UDF, and it works but i can't specify the sender name or sender account if you have an idea too ^^

Edited by YoannMorl

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

[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

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

@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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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
========================================================

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

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

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

In outlook, i can change the from line when a create a new mail. A the top of the window, i have a dropdown list with all accounts.

Id like to force user to use a specific mail (from) by default.

Edited by YoannMorl

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Tried but it's seems to not working, i stay the sender of the mail.

Share this post


Link to post
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 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
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
Sign in to follow this  
Followers 0