Hi all,
i need to give the text of selected mail object for:
search for a 14 char string witch begin with IT001E followed by "nnnnnnnn"
start one macro to search the 14 char string into other web application (and this it not a problem)
so, one step at time, how to have complete mail object string from the preview box of Outlook ?
... with COM if it possible
Outlook 2013 - How give text of mail object ?
- FanaticGuru
- Posts: 1905
- Joined: 30 Sep 2013, 22:25
Re: Outlook 2013 - How give text of mail object ?
Not real sure what you are looking for but here is a start.
This will loop through the selected emails in Outlook and display the subject of each of those emails.You could do lot of different things with those selected emails.
Here is the MSDN of a MailItem
https://msdn.microsoft.com/en-us/librar ... 61332.aspx
After Email in the code you can change Subject to any of the Methods or Properties listed. Methods cause an action to occur like Delete. Properties gets or sets information like Subject.
FG
This will loop through the selected emails in Outlook and display the subject of each of those emails.
Code: Select all
F12::
Emails := ComObjActive("Outlook.Application").ActiveExplorer.Selection
For Email in Emails
MsgBox % Email.Subject
return
Here is the MSDN of a MailItem
https://msdn.microsoft.com/en-us/librar ... 61332.aspx
After Email in the code you can change Subject to any of the Methods or Properties listed. Methods cause an action to occur like Delete. Properties gets or sets information like Subject.
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Outlook 2013 - How give text of mail object ?
Now ... all work ok but I want to simply "replay" to this mail.
Then my routine search object for "IT001Ennnnnn" and open new mail ...
Like write before I need now to simply "open" replay box from selected mail item ... help
Code: Select all
Emails := ComObjActive("Outlook.Application").ActiveExplorer.Selection
For Email in Emails
OggettoMail := Email.Subject
Like write before I need now to simply "open" replay box from selected mail item ... help
- FanaticGuru
- Posts: 1905
- Joined: 30 Sep 2013, 22:25
Re: Outlook 2013 - How give text of mail object ?
Below code will reply to the first email in selection.
FG
Code: Select all
Emails := ComObjActive("Outlook.Application").ActiveExplorer.Selection ; get all emails selected
Email_Reply := Emails.Item(1).Reply ; create reply to the first email
Email_Reply.Display ; display the reply
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Outlook 2013 - How give text of mail object ?
Thanks, it's simply but I have problem to find solution
after, if want write something into reply:
after, if want write something into reply:
Code: Select all
myInspector := Email_Reply.GetInspector, myInspector.Activate
wdDoc := myInspector.WordEditor
wdRange := wdDoc.Range(0, wdDoc.Characters.Count)
wdRange.InsertBefore("... body text HERE ...") ; or put text into variable: wdRange.InsertBefore(variable)
Last edited by scriptors on 26 Jun 2017, 04:34, edited 1 time in total.
Re: Outlook 2013 - How give text of mail object ?
and, if you want to Reply all persons into email:
Emails := ComObjActive("Outlook.Application").ActiveExplorer.Selection ; get all emails selected
Email_Reply := Emails.Item(1).ReplyAll ; create reply to the first email with ALL adress
Email_Reply.Display ; display the reply
Emails := ComObjActive("Outlook.Application").ActiveExplorer.Selection ; get all emails selected
Email_Reply := Emails.Item(1).ReplyAll ; create reply to the first email with ALL adress
Email_Reply.Display ; display the reply
- FanaticGuru
- Posts: 1905
- Joined: 30 Sep 2013, 22:25
Re: Outlook 2013 - How give text of mail object ?
To set the "body" of an email is very simple:scriptors wrote:Thanks, it's simply but I have problem to find solution
after, if want write something into reply:
Code: Select all
myInspector := Email_Reply.GetInspector, myInspector.Activate wdDoc := myInspector.WordEditor wdRange := wdDoc.Range(0, wdDoc.Characters.Count) wdRange.InsertBefore("... body text HERE ...") ; or put text into variable: wdRange.InsertBefore(variable)
Code: Select all
Email_Reply.Body := "This is a test." ; Make the body of the email this
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
- FanaticGuru
- Posts: 1905
- Joined: 30 Sep 2013, 22:25
Re: Outlook 2013 - How give text of mail object ?
If you want a fancier, HTML email, instead of just plain text you can do this:
FG
Code: Select all
Picture := A_Desktop "\Temp\1024x1024.jpg"
html=
(
<html>
<body>
<font size="2" face="Calibri" color="black">
<p>Best Regards,<br>Have a nice day!<br>More Greetings and e-mails and that sort of stuff<br><br>
<b><font size="2">
Your Name</b><br>
<a href="mailto:[email protected]">[email protected]</a><br>
<img src=%Picture% alt="My picture";">
</body>
</html>
)
Email_Reply.HTMLBody := html
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Re: Outlook 2013 - How give text of mail object ?
I search and make "script" posted below because have my personal signature on e-mail ...
now i'm not sure ... but if i set Email.Body have problem with signature
ps. i hope write correct english
now i'm not sure ... but if i set Email.Body have problem with signature
ps. i hope write correct english
- FanaticGuru
- Posts: 1905
- Joined: 30 Sep 2013, 22:25
Re: Outlook 2013 - How give text of mail object ?
You might try this is you want to keep the existing body of an email and insert new stuff at beginning.scriptors wrote:I search and make "script" posted below because have my personal signature on e-mail ...
now i'm not sure ... but if i set Email.Body have problem with signature
ps. i hope write correct english
Code: Select all
Emails := ComObjActive("Outlook.Application").ActiveExplorer.Selection ; get all emails selected
Email_Reply := Emails.Item(1).ReplyAll ; create replyall to the first email
Email_Reply.Display ; display the reply
Email_Reply.HTMLBody := "This is a test." Email_Reply.HTMLBody ; Insert to beginning of html body of email
FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
Who is online
Users browsing this forum: Google [Bot] and 185 guests