i have this code, i copied data from Excel and then i want to paste them into the email body with signature under the text
and i want to keep formating from Excel.
Everything works fine, but the last command Ol.send works only if Ol.Display is true, but i want to send this email on background.
if i remove part of inspector and wordEditor and just put some text in body, then outlook send email on background but dont send the email if i use word Editor :/
Any tips please?
Thank you!
Code: Select all
path1 := "f:\template\test_data_querry_template.xlsx"
XL := ComObjCreate("Excel.Application")
XL.Visible := 0
XL.DisplayAlerts := False
XL.Workbooks.Open(Path1)
XL.ActiveWorkbook.RefreshAll
sleep, 200
XL.ActiveSheet.UsedRange.copy
sleep, 300
XL.ActiveWorkbook.Close(False)
XL.Quit()
XL := ""
Ol := ComObjCreate("Outlook.Application").CreateItem(0)
Ol.Subject := "novy mail"
Ol.to := "[email protected]"
;Ol.HTMLBody := Clipboard ; this works fine but i will lose formating (same if i use just Ol.body = )
Ol.Display ; without this i cant send email
myInspector := Ol.GetInspector
wdDoc := myInspector.WordEditor
wdRange := wdDoc.Range(0, wdDoc.Characters.Count)
wdRange.InsertBefore("")
wdRange.paste
Ol.Send
return