Jump to content

Recommended Posts

Posted
  On 12/8/2016 at 12:35 PM, water said:

If you create a mail item and add "Raffaello Vaselli" as recipient is Outlook able to resolve to a valid address?
Seems that Outlook is not able to resolve the recipient because there is no address book with such an entry.

Expand  

yeap, i dont use address book

i only use suggested contact

 

 

Posted

Maybe this works:

#include <OutlookEX.au3>
Global $oOL = _OL_Open()
Global $oCurrentUser = $oOL.GetNameSpace("MAPI").CurrentUser
MsgBox(0, "", IsObj($oCurrentUser))

 

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Do you still get "1" when removing your contact from the addressbook?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

That's great! Could you please replace

$oOL.GetNameSpace("MAPI").CurrentUser.Name

with

$oOL.GetNameSpace("MAPI").CurrentUser

in function _OL_TestEnvironmentCreate?
Currentuser should return the Recipient object so the meeting object should be created without problems (if I'm not wrong as I can not test at the moment).

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 12/8/2016 at 1:55 PM, water said:

That's great! Could you please replace

$oOL.GetNameSpace("MAPI").CurrentUser.Name

with

$oOL.GetNameSpace("MAPI").CurrentUser

in function _OL_TestEnvironmentCreate?
Currentuser should return the Recipient object so the meeting object should be created without problems (if I'm not wrong as I can not test at the moment).

Expand  

 

Worked

 

 

 

 

 

 

Posted

Great :)
Will check if it still works in an Exchange server environment. If it does, the next version of the UDF will include this modification.
Thanks for your patience!

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

@water

thanks you,

 

but now i got some error on some exemple scripts

_OL_ItemCreate

it stop on 1 one

i also change the :

$oItem = _OL_ItemCreate($oOutlook, $olAppointmentItem, "*\Outlook-UDF-Test\TargetFolder\Calendar", "", "Subject=TestSubject", "Start=" & _NowCalc(), "End=" & _DateAdd("h", 3, _NowCalc()), _
        "Location=Building A, Room 10", "RequiredAttendees=" & $oOutlook.GetNameSpace("MAPI" ).CurrentUser)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error creating an appointment in folder 'Outlook-UDF-Test\TargetFolder\Calendar'. @error = " & @error & ", @extended = " & @extended)

i get the error 1 | ext 4

Posted

Replacing "CurrentUser.Name" with "CurrentUser" does not work in the examples because the functions need the parameters as strings.
Could you try "$oOL.Session.Accounts.Item(1).SMTPaddress" instead?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 12/8/2016 at 3:24 PM, water said:

Replacing "CurrentUser.Name" with "CurrentUser" does not work in the examples because the functions need the parameters as strings.
Could you try "$oOL.Session.Accounts.Item(1).SMTPaddress" instead?

Expand  

Where, and how?

 

@water

maybe is better and easy to tell what i what

i want o open a  Template email, edit some variable(text) on body

Posted
  1. In all example scripts - like _OL_ItemCreate.au3 - where you did notice an error
  2. Example 5 in _OL_ItemCreate.au3 explains how to create a new mail from a template.

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)
  On 12/8/2016 at 3:57 PM, water said:
  1. In all example scripts - like _OL_ItemCreate.au3 - where you did notice an error
  2. Example 5 in _OL_ItemCreate.au3 explains how to create a new mail from a template.
Expand  

1- i could not find  where "Could you try "$oOL.Session.Accounts.Item(1).SMTPaddress" instead?"

2- i stated using the ex 5 but i cant get so far :( 

i get the ex tamplete on target folder,but i cant figured how to  edit/modify it

i will do some search

 

on the photo  is my template, and the body text in red it the part of the text that i want to change.

 

 

Capture.PNG

Edited by Raffav
Posted

Is the body of the mail in format "Text" or "HTML"?

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted (edited)
  On 12/8/2016 at 10:40 PM, water said:

Is the body of the mail in format "Text" or "HTML"?

Expand  

HTML

i was able to add a new text on the bottom

#include <OutlookEX.au3>
Global $oItem
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)
Global $Result = _OL_TestEnvironmentCreate($oOutlook)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF - Manage Test Environment", "Error creating the test environment. @error = " & @error & ", @extended = " & @extended)
$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*\Outlook-UDF-Test\TargetFolder\Mail", @ScriptDir & "\ENC_AWBB--(AWBBxxxx).oft")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error creating a mail in folder 'Outlook-UDF-Test\TargetFolder\Mail'. @error = " & @error & ", @extended = " & @extended)
$asBody = _OL_ItemGet($oOutlook, $oItem, Default, "HTMLBody")
$asBody[1][1] = "teste --> okok"
_OL_ItemModify($oOutlook, $oItem, Default, "HTMLBody=" & $asBody[1][1])
;~ $asBody = _OL_ItemGet($oOutlook, $oItem, Default, "BodyFormat")
;~ _ArrayDisplay($asBody)
$oitem.Display
_OL_Close($oOutlook)

 

Edited by Raffav
Posted

Based on Example 5 it should look like this:

#include <OutlookEX.au3>

Global $oItem
Global $oOutlook = _OL_Open()
Global $Result = _OL_TestEnvironmentCreate($oOutlook)

$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*\Outlook-UDF-Test\TargetFolder\Mail", @ScriptDir & "\_OL_ItemCreate.oft")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error creating a mail in folder 'Outlook-UDF-Test\TargetFolder\Mail'. @error = " & @error & ", @extended = " & @extended)

; Retrieve the current mail body (HTML)
$sHTML = $oItem.HTMLBody
; Modify place holders
$sHTML = StringReplace($sHTML, "Boa tarde ", "Good day ")
$sHTML = StringReplace($sHTML, "IPREDEVSAT", "EMPRESA")
; Rewrite the mail body
$oItem.HTMLBody = $sHTML
_OL_Close($oOutlook)

 

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 12/9/2016 at 11:56 AM, water said:

Based on Example 5 it should look like this:

#include <OutlookEX.au3>

Global $oItem
Global $oOutlook = _OL_Open()
Global $Result = _OL_TestEnvironmentCreate($oOutlook)

$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*\Outlook-UDF-Test\TargetFolder\Mail", @ScriptDir & "\_OL_ItemCreate.oft")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error creating a mail in folder 'Outlook-UDF-Test\TargetFolder\Mail'. @error = " & @error & ", @extended = " & @extended)

; Retrieve the current mail body (HTML)
$sHTML = $oItem.HTMLBody
; Modify place holders
$sHTML = StringReplace($sHTML, "Boa tarde ", "Good day ")
$sHTML = StringReplace($sHTML, "IPREDEVSAT", "EMPRESA")
; Rewrite the mail body
$oItem.HTMLBody = $sHTML
_OL_Close($oOutlook)

 

Expand  

sorry is not working

Posted

I needed to change two things:

  • The item needs to be saved before we can access certain properties
  • We need to modify other words in the mail template
#include <OutlookEX.au3>

Global $oItem
Global $oOutlook = _OL_Open()
Global $Result = _OL_TestEnvironmentCreate($oOutlook)

$oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*\Outlook-UDF-Test\TargetFolder\Mail", @ScriptDir & "\_OL_ItemCreate.oft")
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemCreate Example Script", "Error creating a mail in folder 'Outlook-UDF-Test\TargetFolder\Mail'. @error = " & @error & ", @extended = " & @extended)
$oItem.Save()
; Retrieve the current mail body (HTML)
$sHTML = $oItem.HTMLBody
; Modify place holders
$sHTML = StringReplace($sHTML, "Example mail", "Exemplo de correio")
$sHTML = StringReplace($sHTML, "template", "modelo")
; Rewrite the mail body
$oItem.HTMLBody = $sHTML
; Display the changed item
$oItem.Display

 

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

Example 1 in _OL_ItemCreate.au3 shows how to use MS Word to fully edit a mail item.
Warning: This might become complex ;)

My UDFs and Tutorials:

  Reveal hidden contents

 

Guest
This topic is now closed to further replies.
×
×
  • Create New...