Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #SingleInstance, Force
- ;https://docs.microsoft.com/en-us/office/vba/api/outlook.mailitem.actions
- ; BASIC INTRO FOR OUTLOOK
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- /*
- MailItem := ComObjActive("Outlook.Application").CreateItem(0) ; Create a new MailItem object
- ;~ MsgBox, % IsObject(MailItem) ; testing if it is an object
- MailItem.SendUsingAccount := Mail.Application.Session.Accounts.Item["[email protected]"] ; Assign which accont to use (can also use NameSpace)
- MailItem.BodyFormat := 2 ; Outllok Constants: 1=Text 2=HTML 3=RTF
- MailItem.TO :="" ; Seperate by ; if you want to have multiple
- MailItem.CC := ""
- MailItem.Subject := "Example subject line"
- ;~ MailItem.Attachement.Add("B:\folder\folder2\AHK_BALL.jpg")
- ;~ MailItem.Importance := 2 ; 0=Low 1=normal 2=High
- ;~ MailItem.DeferredDeliveryTime := "1/6/12 10:40:00 AM"
- ;~ MailItem.OriginatorDeliveryReportRequest := 1 ;request a delivery Reciept
- ;~ MailItem.ReadReceiptRequested := ; Requesta read receipt
- Name := "Bob"
- Body =
- ( Join comments
- <HTML>
- <p>Hi there %Name%, </p> ; this is comment
- <p>Just saying hello </p>
- </HTML>
- )
- MailItem.HTMLBody := Body
- MailItem.Display
- ;~ MailItem.Close(0) ; Creates draft version in default folder
- ;~ MailItem.Send() ; Sends the email
- Return
- */
- ; PERSONALIZE EMAILS
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- /*
- var =
- (
- Email First_Name Last_Name
- [email protected] Jonas Burbuliavicius
- [email protected] Petras Slekys
- )
- ; *********Use For Loop over var (variable) going line by line********************
- for i, row in Loopobj:=StrSplit(var,"`n") { ;Parse Var on each new line
- IfEqual, i,1,continue ;Skip header row
- ;~ IfLessOrEqual,i,4382, continue
- IfEqual,row,,continue ; Skip loop if blank
- Menu, tray, tip, % i-1 " of " Loopobj.maxindex()-1 " : email is " StrSplit(row,"`t").1 ;Show progress on icon in system tray
- ;~ MsgBox, % StrSplit(row,"`t").1 A_Tab StrSplit(row,"`t").2 A_Tab StrSplit(row,"`t").3 ; demonstrate values
- MailItem := ComObjActive("Outlook.Application").CreateItem(0) ; Create a new MailItem object
- ;~ MsgBox, % IsObject(MailItem) ; testing if it is an object
- MailItem.SendUsingAccount := Mail.Application.Session.Accounts.Item["[email protected]"] ; Assign which account to use (can also use NameSpace
- MailItem.BodyFormat := 2 ; Outllok Constants: 1=Text 2=HTML 3=RTF
- MailItem.TO :=StrSplit(row,"`t").1 ; Seperate by ; if you want to have multiple
- MailItem.Subject := "Example subject line"
- Name := StrSplit(row,"`t").2
- LastName := StrSplit(row,"`t").3
- Body =
- ( Join comments
- <HTML>
- <p>Hi there %Name% %LastName% </p> ; this is comment
- <p>Just saying hello </p>
- </HTML>
- )
- MailItem.HTMLBody := Body
- MailItem.Display
- MsgBox, pause
- } ; brackets of for loop
- ;~ MailItem.Close(0) ; Creates draft version in default folder
- ;~ MailItem.Send() ; Sends the email
- return
- */
- ; PERSONALIZE EMAILS AND TAKE INFO FROM EXCEL DATABASE
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ; https://www.youtube.com/watch?v=cvZEE7v22wE
- ; time 32:49
- ; Su email susijes pavyzdys
- !Numpad1::
- subjectField := "This is Subject field"
- contentField := "This is my msg and content"
- Run, mailto:Rimantas.Danilevicius@cognizant.com?subject=%aaa%&body=%bbb%
- return
- ;******************************************************************************************************************************************
- ;******************************************************************************************************************************************
- ;******************************************************************************************************************************************
- mail := ComObjActive("Outlook.Application").GetNameSpace("MAPI").GetDefaultFolder[6] ; Inbox
- Loop % mail.Items.Count { ; Loop over emails
- if Instr(mail.Items[A_Index].SenderName,"Google Alerts") { ; Filter emails to just being sent by Google Alerts
- MsgBox % "To: " mail.Items[A_Index].To "`r`r"
- . "Subject: `t" mail.Items[A_Index].Subject "`r`r"
- . "Body: `t" mail.Items[A_Index].Body "`r`r"
- }
- }
- return
- ;******************************************************************************************************************************************
- ;******************************************************************************************************************************************
- ;******************************************************************************************************************************************
- ^o::
- Haystack =
- (
- Hello tom12@run.com more text,
- worked and joe.glines@gmail.com,
- did too and JoeShmoe@ai.com,
- this alsi works joes@school.edu,
- 432 444 Joe@marketing.cn 789456
- this is one more example Joe@the_automaror.com was here
- a|a|a|a
- )
- /*; this part read every line
- words := StrSplit(Haystack, "|") ; suveikia kaip explode
- for k,v in words
- MsgBox % v ; atvaizduoja po viena reiksme
- */
- /*; this part read every line
- words := StrSplit(Haystack,[" ", "`n", "|"]) ; suveikia kaip explode tik su daugiau variantu
- for k,v in words
- Msgbox % v ; atvaizduoja po viena reiksme
- */
- words := StrSplit(Haystack,[" ", "`n", "|"]) ; suveikia kaip explode tik su daugiau variantu
- for k,v in words
- if(InStr(v,"@"))
- emails.= v "`n" ; append value and new line to emails // sita vieta ir tokiu uzrasymu galima storinti issaugoti reiksmes is for kur gaunam
- ;~ Msgbox % emails
- FileAppend % emails, C:\Users\Rimas\Desktop\ahk_stuff\test1.txt
- return
- Pos :=1 ;set starting point
- loop, {
- Found_Pos := RegExMatch(Haystack, "(?:[\w_\.-]+)@(?:[\w\.-]+)\.(?:[a-z\.]{2,6})", Obj, Pos) ;
- Pos := Found_Pos + StrLen(Obj) + 1
- if not Obj ;if not found stop looping
- break
- emails .=Obj " `r" ;add to emails variable
- }
- MsgBox % emails
- return
- ;******************************************************************************************************************************************
- ;******************************************************************************************************************************************
- ;******************************************************************************************************************************************
- ; LOOP THOUGH OUTLOOK FOLDERS
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;time 39:45
- /*
- ; mail := ComObjActive("Outlook.Application").GetNameSpace("MAPI").GetDefaultFolder[6] ; Inbox
- mail := ComObjActive("Outlook.Application").GetNameSpace("MAPI").GetDefaultFolder[6].Folders("AutoHotKey")
- MsgBox, % "There are " mail.Items.Count " emails in the " mail.Name " folder"
- Loop % mail.Items.Count
- {
- ;~ if instr(mail.Items[A_Index].SenderName,"Joe Glines") {
- if instr(mail.Items[A_Index].Subject,"Autohotkey") {
- Item := mail.Items(A_Index) ; Sets Item to the values of the selected email
- MsgBox, % "To: `t" Item.To "`nSubject:`t" Item.Subject ; . "`nBody:`t" Item.Body
- ; mail.Items[A_Index].Display() ;show emails
- }
- }
- return
- */
- ; KAZKOKS KITAS APPROACHAS
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;https://www.autohotkey.com/boards/viewtopic.php?t=67224
- /*
- oOutlook := ComObjActive("Outlook.Application") ; MsgBox, % COMObjActive("Outlook.Application").ActiveExplorer.Selection.Item(1).SenderName ; neaisku kurioje vietoje sitas turi buti, galv ietoje 209 eilutes
- oInspector := oOutlook.Application.ActiveInspector
- MsgBox, % COMObjActive("Outlook.Application").ActiveExplorer.Selection.Item(1).SenderName ; neaisku kurioje vietoje sitas turi buti
- Mail := oInspector.CurrentItem ; getting current email object
- ; Email-properties-list
- ; https msdn.microsoft.com /en-us/library/office/ff868262.aspx Broken Link for safety
- m_subject:=mail.subject
- m_senderemailaddress:=mail.senderemailaddress ; "[email protected]"
- m_sendername:=RegExReplace(mail.sendername,"[^\w ]")
- m_ReceivedTime:=mail.ReceivedTime ; "03.04.2015 15:38:56"
- return
- */
- ; MOVE FOLDERS TO ANOTHER FOLDER
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
- ;You need to adjust the folder and/or subfolders structure which will be similar to a path.
- ;Hi guys, i am trying to move selected emails to a folder without success
- ; https://www.autohotkey.com/boards/viewtopic.php?t=63301
- /*
- F12::
- olApp := ComObjCreate("Outlook.Application")
- olNameSpace := olApp.GetNamespace("MAPI")
- olDestFolder := olNameSpace.Folders("[email protected]").Folders("Deleted Items")
- olEmails := olApp.ActiveExplorer.Selection
- For olEmail in olEmails
- olEmail.Move(olDestFolder)
- return
- */
- ; --------------------------------------------------------------------------------------------------------------------------------------------------------
- ; ######################### Find folder in outlook - need to check #########################
- ; --------------------------------------------------------------------------------------------------------------------------------------------------------
- ^!j::
- Mail := ComObjActive("Outlook.Application").GetNameSpace("MAPI").GetDefaultFolder[6].Folders("Automate")
- Loop % mail.items.Count {
- MsgBox % mail.items[a_index].SenderName a_tab mail.items[a_index].subject
- }
- return
- ; --------------------------------------------------------------------------------------------------------------------------------------------------------
- ; ######################### Find recieved time from outlook email #########################
- ; --------------------------------------------------------------------------------------------------------------------------------------------------------
- ;example from fornum: https://www.autohotkey.com/boards/viewtopic.php?f=76&t=80825&p=351742#p351742
- ; regex \d{8}\s[a-zA-Z]+\s\d|\d{8} find fornyelsecode or just number
- F5::
- olApp := ComObjCreate("Outlook.Application")
- olNameSpace := olApp.GetNamespace("MAPI")
- sSubject := "VM8743"
- for olItem in olFolder.Items.Restrict("@SQL=""http://schemas.microsoft.com/mapi/proptag/0x0037001f"" = '" sSubject "'")
- MsgBox % olItem.CreationTime "`n" olItem.ReceivedTime "`n" olItem.Subject "`n" olItem.Body ; Any valid Item property will work here
- return
- !r::Reload
- !z::Pause
- !x::ExitApp
Add Comment
Please, Sign In to add comment