I'm trying to create a script that retrieves the sender's name and email address from a selected or opened mail in Outlook (2016, if that matters) and then creates a new Contact with that info. I'm using the code from the GitHub posted by kon and have come up with this so far:
Code: Select all
olApp:=ComObjCreate("Outlook.Application") ; Create an application object
olMail:=olApp.GetActiveItem(olMailItem) ; *** I know this is wrong - what should it be? ***
ContactEmail:=olMail.SenderEmailAddress ; get sender's email address
ContactName:=olMail.SenderName ; get sender's name
olContact:=olApp.CreateItem(olContactItem) ; Create a new Contact
olContact.Email1Address:=ContactEmail ; put sender's email address in Email1 field
olContact.FullName:=ContactName ; put sender's name in FullName field