Jump to content

Recommended Posts

Posted

Hi,

 

I have used Outlook UDF to create email.

Not in $bodyvar which is email body i need to copy something like $OWorkbook.ActiveSheet.Range("A1:F25").Copy and paste in $Bodyvar.

How i can do it pls?

thanks,

Posted

Hi,

 

I am getting this error:Variable used without being declared.:

Also excel has chart which i want to copy in body.

 

Posted

Depends on the format of the Outlook mail you use. Is it HTML or RTF?

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

 

Posted
Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\1234".xlsx")

Global $oOutlook = _OL_Open()
Global $bodyvar=_Excel_RangeRead($oWorkbook, 1, "A1:F25")


_OL_Wrapper_SendMail(... )

this is my code. in excel i have chart and table which i want in body

Posted

When using COM you do not automate the Outlook GUI but you use an API to directly interact with Outlook core.
I suggest to save the chart to a file and then imbed it into the mail body.
The example script for _OL_ItemCreate has an example how to add a Picture inline (Example 4).
 

 

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

 

Posted

Hi,

 

I saw  _OL_ItemCreate function but do not see any example. how to add excel stuff when create email. 

Sorry I am not that Pro who can understand quickly.

Posted

This works for me, have fun off to have some zzzzzzzzz.

#include <Excel.au3>

$oExcel = _Excel_Open()
$oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Chart.xlsx")
$oRange = $oWorkbook.ActiveSheet.Range("A1:G34").Select
$oExcel.CopyObjectsWithCells = True
$oExcel.Selection.Copy

$oOutlook = ObjCreate("Outlook.Application")
$oMail = $oOutlook.CreateItem(0)

$oMail.Display
$oMail.To = "sample@example.com"
$oMail.Subject = "Sample Subject"
$oWordEditor = $oOutlook.ActiveInspector.wordEditor
$oMail.Body = "Hello" & @CRLF & "Please find charts above." & @CRLF & @CRLF & "Regards Subz"
$oWordEditor.Range(0, 0).Select
$oWordEditor.Application.Selection.Paste
$oMail.Display
Posted

Hi,

 

I am getting this error Variable must be of type "Object" at this line:

$oRange = $oWorkbook.ActiveSheet.Range("A1:G34").Select

idea?

Posted

What is the value of @error after _Excel_BookOpen?

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

 

Posted
$oExcel = _Excel_Open()
$oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Report.xlsx")
Sleep(5000)
$oRange = $oWorkbook.ActiveSheet.Range("A1:A5").Select
If @error Then
    MsgBox(0,"",@error)
EndIf
$oExcel.CopyObjectsWithCells = True
$oExcel.Selection.Copy

$oOutlook = ObjCreate("Outlook.Application")
$oMail = $oOutlook.CreateItem(0)

$oMail.Display
$oMail.To = "vp@xxx.com"
$oMail.Subject = "Sample Subject"
$oWordEditor = $oOutlook.ActiveInspector.wordEditor
$oMail.Body = "Hello" & @CRLF & "Please find charts above." & @CRLF & @CRLF & "Regards vp"
$oWordEditor.Range(0, 0).Select
$oWordEditor.Application.Selection.Paste
$oMail.Display

this is my script

Posted

Your code works for me. Have you enabled macros and lowered excel security?

Try changing

$oRange = $oWorkbook.ActiveSheet.Range("A1:G34").Select

to

$oRange = $oWorkbook.Application.ActiveSheet.Range("A1:G34").Select
Posted

hi,

 

i found one issue here that what i put in email body like text 

"Hello" & @CRLF & "Please find charts above." & @CRLF & @CRLF & "Regards vp"

goes always after my copy part from excel. i want it in first line then paste.

How i can do it pls?

Posted

Try:

#include <Excel.au3>

Local $oExcel = _Excel_Open()
Local $oWorkbook = _Excel_BookOpen($oExcel, @ScriptDir & "\Chart.xlsx")
Local $oRange = $oWorkbook.ActiveSheet.Range("A1:G34").Select
    $oExcel.CopyObjectsWithCells = True
    $oExcel.Selection.Copy

Local $oOutlook = ObjCreate("Outlook.Application")
Local $oMail = $oOutlook.CreateItem(0)
    $oMail.Display
    $oMail.To = "sample@example.com"
    $oMail.Subject = "Sample Subject"

Local $sBodyHeader = "Hello" & @CRLF & @CRLF & "Please find charts below." & @CRLF & @CRLF
Local $sBodyFooter = @CRLF & @CRLF & "Regards Subz"

Local $oWordEditor = $oOutlook.ActiveInspector.wordEditor
    $oWordEditor.Range(0, 0).Select
    $oWordEditor.Application.Selection.TypeText($sBodyHeader)
    $oWordEditor.Application.Selection.Paste
    $oWordEditor.Application.Selection.TypeText($sBodyFooter)

$oMail.Display

 

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
×
×
  • Create New...