Jump to content

OutlookEX UDF - Help & Support (III)


water
 Share

Recommended Posts

Can you please post the code you run?

 

Here you go:

Func SendEmail()
    $oOL = _OL_Open()
    $oItem = _OL_ItemCreate($oOL, $olMailItem, '', '', 'Subject=' & ReplaceStringVariables($email_subj), 'Importance=' & $olImportanceHigh)
    $oItem.BodyFormat = $olFormatHTML
    $oItem.GetInspector
    $sBody = $oItem.HTMLBody
    $oItem.HTMLBody = ReplaceStringVariables($email_body) & $sBody
    _OL_ItemRecipientAdd($oOL, $oItem, Default, $olCc, $email_cc)
    _OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, $email_to)
    _OL_ItemAttachmentAdd($oOL, $oItem, Default, $spt_file, $par_file)
    $oItem.Display
    _OL_Close($oOL)
EndFunc

If I switch _OL_ItemRecipientAdd($oOL, $oItem, Default, $olCc, $email_cc) and _OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, $email_to) around so that _OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, $email_to) is first, then any recipients in _OL_ItemRecipientAdd($oOL, $oItem, Default, $olCc, $email_cc) get added to the To: field. If I leave it as in the code snippet above it works properly (both To: and Cc: recipients end up in the right fields).

Link to comment
Share on other sites

Hi guys,

I am trying to create an email with a very specific template. Like font color, different size here and there, different font and ...

 

But I am not quite sure how to use this example : 

$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=Subject for BodyFormat=HTML")
$oItem.BodyFormat = $olFormatHTML
$oItem.GetInspector
$sBody = $oItem.HTMLBody
$oItem.HTMLBody = "HTML: <b>Mail</b> Text" & $sBody
$oItem.Display

And insert a bunch of HTML code in that. 

I have managed to view the source code of the email template I am trying to create, see below.

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
    {font-family:Calibri;
    panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
    {font-family:Verdana;
    panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
    {margin:0cm;
    margin-bottom:.0001pt;
    font-size:12.0pt;
    font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
    {mso-style-priority:99;
    color:blue;
    text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
    {mso-style-priority:99;
    color:purple;
    text-decoration:underline;}
span.EmailStyle17
    {mso-style-type:personal-compose;
    font-family:"Arial","sans-serif";}
.MsoChpDefault
    {mso-style-type:export-only;
    font-size:10.0pt;}
@page WordSection1
    {size:612.0pt 792.0pt;
    margin:72.0pt 90.0pt 72.0pt 90.0pt;}
div.WordSection1
    {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=FR-CA link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hello,<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>I tried to reach you without success..&nbsp;<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>please call me back  <span style='color:#3366FF'>&lt;</span><span style='color:blue'>&nbsp;5 days</span><span style='color:#3366FF'>&nbsp;&gt;</span> some more text here <span style='color:black'>ticket number n<sup>o</sup></span><span style='color:blue'> INTERACTION</span><span style='color:#3366FF'>&gt;</span>.Some text here.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>Some more text.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal>fsfsdfdsf demande&nbsp;en&nbsp;ligne&nbsp; <a href="blocked::blocked::blocked::www.google.com" title="www.google.com</a>.<o:p></o:p></p><p class=MsoNormal>&nbsp;<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><p class=MsoNormal><b><span style='font-size:10.0pt;font-variant:small-caps'>Help and stuff additionnels<o:p></o:p></span></b></p><p class=MsoNormal>Something here <a href="blocked::blocked::blocked::google.com" title="Google.com">Normal</a>, So,ething.<o:p></o:p></p><p class=MsoNormal><o:p>&nbsp;</o:p></p><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:black'>sdfdf</span></b><br><span style='font-size:7.5pt;font-family:"Verdana","sans-serif"'>fsdffsdf</span><br><span style='font-size:7.5pt;font-family:"Verdana","sans-serif"'>fsdff</span><br><span style='font-size:7.5pt;font-family:"Verdana","sans-serif"'>fdsffsdfe<o:p></o:p></span></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><span style='font-size:7.5pt;font-family:"Verdana","sans-serif"'>Externe&nbsp;: 514 840 3000 x7869</span><br><span style='font-size:7.5pt;font-family:"Verdana","sans-serif"'>Tlphone : 0-840-7869</span><br><b><span style='font-size:7.5pt;font-family:"Verdana","sans-serif";color:blue'><a href="http://groupetechnologie.hydro.qc.ca/centre_de_services_tic/index.htm">Centre de services TIC</a></span></b><span style='font-size:7.5pt;font-family:"Verdana","sans-serif"'><o:p></o:p></span></p><p class=MsoNormal><span style='font-size:7.5pt;font-family:"Arial","sans-serif"'><o:p>&nbsp;</o:p></span></p></div><p class=MsoNormal><o:p>&nbsp;</o:p></p></div></body></html>

Is there a " fast way" to use all of that, or do I have to go through it and format everyting in the right language?

Edited by PinetSebastien
Link to comment
Share on other sites

To create an item based on a template I would set parameter 4 to the name of the template file:

$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "name of the template file goes here", "Subject=Subject for BodyFormat=HTML", "BodyFormat=" & $olFormatHTML)
$oItem.GetInspector
$sBody = $oItem.HTMLBody
$oItem.HTMLBody = "HTML: <b>Mail</b> Text" & $sBody
$oItem.Display

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

@water

It works, but It means I have to use a .oft file on my workstation? And that won`t really work because I need to use this script I am making with a bunch of workstations. 

Edit : Here is exactly what I'm trying to do.

I'm working on a GUI that will have 2 input box

1- Name of the person to send  the email to.

2- The ticket number that person uses.

And I'm gonna have a button that will send an email template to that person,  but in the template( email body), I have to change the name and the ticket number mentionned in it.

The templates are already created, but we have to edit it everytime we want to send an email to someone.

Edited by PinetSebastien
Link to comment
Share on other sites

Add some placeholder to your template (e.g. "%name%" and %ticket%") and use StringReplace to replace this strings with the real data. In this case you could drop the OFT file.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

How would that work?

Let's say i'm using this code : 

$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=Subject for BodyFormat=HTML")
$oItem.BodyFormat = $olFormatHTML
$oItem.GetInspector
$sBody = $oItem.HTMLBody
$oItem.HTMLBody = " INSERT HTML CODE TEMPLATE HERE " & $sBody

$oItem.Display

I'm guessing I would have to view the source file of my template file, and try to insert it where I typed "insert here" in the code above?

And then change some parts of the templates with placeholders tags?

My main problem right now is trying to insert the HTML source of my email template inside autoit. Because some HTML codes uses the " symbol which I can't really use inside Autoit right?

Like for exemple 

$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", "Subject=Subject for BodyFormat=HTML")
$oItem.BodyFormat = $olFormatHTML
$oItem.GetInspector
$sBody = $oItem.HTMLBody
$oItem.HTMLBody = " <font size="12" face="Times New Roman"> Hi here is your ticket number : ... </font> " & $sBody

$oItem.Display

I can't use size="12" or face=Times new roman

Edited by PinetSebastien
Link to comment
Share on other sites

If I were to write such a script I would first answer the following question: How often will the template need to be changed? Different formatting, change content etc.

Looks like you created the template using MS Word.

I would use FileInstall to include the template file into your compiled script so it can be easily distributed to many users. FileInstall writes the template to a directory on the users computer when the script is being executed. Then read this local file into a variable, replace the placeholders and create the mail.

Sounds a bit complex at first but I think it won't take to much time to do.

Can't test at the moment as I do not have Office installed here.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Ops.. sorry i'dont want disturb you

 

i saw the error ma i don't understand

where is a code for showing me all note of all account of the outlook?

You can only search for notes of the currently logged on account or in shared folders.

Example:

Search all notes of the current user.

#include <OutlookEX.au3>
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)
$aFolder = _OL_FolderAccess($oOutlook, "", $olFolderNotes)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing folder. @error = " & @error & ", @extended = " & @extended)
$aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olNote, "", "", "", "Body")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error searching nots. @error = " & @error & ", @extended = " & @extended)
_ArrayDisplay($aItems)
_OL_Close($oOutlook)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Here you go:

Func SendEmail()
    $oOL = _OL_Open()
    $oItem = _OL_ItemCreate($oOL, $olMailItem, '', '', 'Subject=' & ReplaceStringVariables($email_subj), 'Importance=' & $olImportanceHigh)
    $oItem.BodyFormat = $olFormatHTML
    $oItem.GetInspector
    $sBody = $oItem.HTMLBody
    $oItem.HTMLBody = ReplaceStringVariables($email_body) & $sBody
    _OL_ItemRecipientAdd($oOL, $oItem, Default, $olCc, $email_cc)
    _OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, $email_to)
    _OL_ItemAttachmentAdd($oOL, $oItem, Default, $spt_file, $par_file)
    $oItem.Display
    _OL_Close($oOL)
EndFunc

If I switch _OL_ItemRecipientAdd($oOL, $oItem, Default, $olCc, $email_cc) and _OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, $email_to) around so that _OL_ItemRecipientAdd($oOL, $oItem, Default, $olTo, $email_to) is first, then any recipients in _OL_ItemRecipientAdd($oOL, $oItem, Default, $olCc, $email_cc) get added to the To: field. If I leave it as in the code snippet above it works properly (both To: and Cc: recipients end up in the right fields).

Seems to be an Outlook bug.

When I press the "Check recipients" button (or whatever it is named in English) the CC-recipient is correctly displayed in the CC field but additionally in the To field.

Very strange.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

  • 3 weeks later...

Sure.

Pass the object returned by _OL_PSTCreate to _OL_FolderCreate.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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 seen you deleted your last post.

Did you notice that the parameters for _OL_FolderCreate are used incorrectly in your example?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Hi there. I used this UDF a few years ago and i remember it was pretty easy to use. Now i cannot even get a concting to Outlook. I get this error:
Error creating a connection to Outlook. @error = 1, @extended = -2147221164

I tried googeling the error, but i found nothing.
Autoit: 3.3.12.0

UDF: 1.0.0.0

Link to comment
Share on other sites

This error means: HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

The full version of Outlook is installed on your machine?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Office 365 is the cloud version. The Outlook UDF only works with a local installation of e.g. Outlook 2013.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Office 365 is the cloud version. The Outlook UDF only works with a local installation of e.g. Outlook 2013.

 Office 365 is a License model. In that licensmodel you have the possability to install Full office 2013 localy on the machine (witch i have done). Isnt that the same version as a regular version of office 2013?

Link to comment
Share on other sites

Maybe the problem is caused by this:

Office trial version

The trial version of Office comes without COM components. You get @error = 1 from _OL_Open.

Installing the full Office product over a trial doesn't seem to help. You need to uninstall the trial and then re-install the full product.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...