Read Message that triggered Script

  • Thread starter Thread starter luis_a_roman
  • Start date Start date
Status
Not open for further replies.
L

luis_a_roman

I have a run script in outlook. Want to read the message including the

content for the message that trigger the script. How can I accomplish this?

Guidance and/or sample code will be appreciated.

Luis


200910
 
Are you referring to a "run a script" action attached to an Outlook rule?

The message that triggers the rule is represented by the MailItem argument

for the VBA procedure, e.g.:

Sub RunAScriptRuleRoutine(MyMail As MailItem)

Dim strID As String

Dim olNS As Outlook.NameSpace

Dim msg As Outlook.MailItem

strID = MyMail.EntryID

Set olNS = Application.GetNamespace("MAPI")

Set msg = olNS.GetItemFromID(strID)

MsgBox msg.Body

Set msg = Nothing

Set olNS = Nothing

End Sub

For Outlook VBA basics, see http://outlookcode.com/article.aspx?id=49

For another example of a "run a script" rule actions, see:

http://www.outlookcode.com/codedetail.aspx?id=1494

CAUTION: Using this technique has been known to result in corrupt VBA code.

Be sure to export your code modules or back up the VBAProject.otm file.

Sue Mosher

"luis_a_roman " <u41449@uwe> wrote in message

news:9da901bb94435@uwe...
> I have a run script in outlook. Want to read the message including the
> content for the message that trigger the script. How can I accomplish
> this?

> Guidance and/or sample code will be appreciated.
 
Yes I'm referring to a "run a script" action. Thank you for sharing. I will

read the article that you refer me to. I'm concerned abut the "CAUTION", does

that means that there is the posibility that the otm file can be corrupted?

If the answer is yes, hopefully in the articles referred to there are best

practices to mitigate that risk.

I need to do some testing but I'm assuming the the code below I can select

the subject and the text and perform some parsing?

What I'm trying to do is to set up a "run script" action for particular

emails with a subject of "Self Portal" and parse it to loaded into an Access

Database. Thank you again for sharing.

Luis

Sue Mosher [MVP] wrote:
> Are you referring to a "run a script" action attached to an Outlook rule?
> The message that triggers the rule is represented by the MailItem argument
> for the VBA procedure, e.g.:

> Sub RunAScriptRuleRoutine(MyMail As MailItem)
> Dim strID As String
> Dim olNS As Outlook.NameSpace
> Dim msg As Outlook.MailItem

> strID = MyMail.EntryID
> Set olNS = Application.GetNamespace("MAPI")
> Set msg = olNS.GetItemFromID(strID)
> MsgBox msg.Body

> Set msg = Nothing
> Set olNS = Nothing
> End Sub

> For Outlook VBA basics, see http://outlookcode.com/article.aspx?id=49

> For another example of a "run a script" rule actions, see:

> http://www.outlookcode.com/codedetail.aspx?id=1494

> CAUTION: Using this technique has been known to result in corrupt VBA code.
> Be sure to export your code modules or back up the VBAProject.otm file.
>
> >I have a run script in outlook. Want to read the message including the
> > content for the message that trigger the script. How can I accomplish
> > this?
>

>> Guidance and/or sample code will be appreciated.


 
Yes, the .otm file can become corrupt. Make sure you have a backup.

The example shows how to access the text in the body of the message. For

other properties, see the object browser -- F2 in VBA.

Sue Mosher

"luis_a_roman " <u41449@uwe> wrote in message

news:9dae4ea2b553b@uwe...
> Yes I'm referring to a "run a script" action. Thank you for sharing. I
> will
> read the article that you refer me to. I'm concerned abut the "CAUTION",
> does
> that means that there is the posibility that the otm file can be
> corrupted?
> If the answer is yes, hopefully in the articles referred to there are best
> practices to mitigate that risk.

> I need to do some testing but I'm assuming the the code below I can select
> the subject and the text and perform some parsing?

> What I'm trying to do is to set up a "run script" action for particular
> emails with a subject of "Self Portal" and parse it to loaded into an
> Access
> Database. Thank you again for sharing.

> Luis

> Sue Mosher [MVP] wrote:
> >Are you referring to a "run a script" action attached to an Outlook rule?
> >The message that triggers the rule is represented by the MailItem argument
> >for the VBA procedure, e.g.:
>

>>Sub RunAScriptRuleRoutine(MyMail As MailItem)
> > Dim strID As String
> > Dim olNS As Outlook.NameSpace
> > Dim msg As Outlook.MailItem
>

>> strID = MyMail.EntryID
> > Set olNS = Application.GetNamespace("MAPI")
> > Set msg = olNS.GetItemFromID(strID)
> > MsgBox msg.Body
>

>> Set msg = Nothing
> > Set olNS = Nothing
> >End Sub
>

>>For Outlook VBA basics, see http://outlookcode.com/article.aspx?id=49
>

>>For another example of a "run a script" rule actions, see:
>

>> http://www.outlookcode.com/codedetail.aspx?id=1494
>

>>CAUTION: Using this technique has been known to result in corrupt VBA
> >code.
> >Be sure to export your code modules or back up the VBAProject.otm file.
> >
> >>I have a run script in outlook. Want to read the message including the
> >> content for the message that trigger the script. How can I accomplish
> >> this?
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
B Inconsistent handling of message read/unread status by Outlook Using Outlook 3
R Reply marks read message as unread Using Outlook 1
FirefIy Marking message read only if replied to the message or Ctrl+Q. Possible? Using Outlook 1
R Cannot read Chinese message after import Using Outlook 2
J From column changes when message is read Using Outlook 1
Rupert Dragwater Mail won't show as read Using Outlook 2
Dr. Demento Analogous Outlook code to read info into an array (or collection or whatever) Outlook VBA and Custom Forms 7
R Imap read/unread problem Using Outlook 3
D Can't read some emails - text size too small. Using Outlook 2
B Delete Read Receipts in Your Outlook Outlook VBA and Custom Forms 0
J Increase read pane font size, but NOT image size? Using Outlook 3
J Read Outlook Form fields Outlook VBA and Custom Forms 3
S E-mails marked as read turn back to unread after a couple of seconds Using Outlook 1
M Cannot read the calendar Using Outlook 9
Z Outlook 365 delete reminder you can’t make change to contents of this-read only folder Using Outlook 4
A Inbox didn't got read Outlook VBA and Custom Forms 0
e_a_g_l_e_p_i Is it possible it set the fonts used to read incoming mail Using Outlook 25
R seperate read layout to design in outlook 2016..Help!! Outlook VBA and Custom Forms 3
N Disable Auto Read Receipts sent after using Advanced Find Using Outlook 4
DoctorJellybean Outlook 365 doesn't always mark emails as read Using Outlook 3
N Separate Read Layout Editing Outlook VBA and Custom Forms 0
A Read and Write to Text File Outlook VBA and Custom Forms 1
L Email Read and Delete Outlook VBA and Custom Forms 4
A Separate Read Layout Outlook VBA and Custom Forms 4
M Making Subject field writable (disable Read Only) Outlook VBA and Custom Forms 2
M How can I determine which user read an email Exchange Server Administration 4
Diane Poremsky Mark Sent Items as Read After Copying with a Rule Using Outlook 0
Diane Poremsky Edit and Save Outlook's Read-Only Attachments Using Outlook 0
Rupert Dragwater Some mailboxes show deleted items as not read Using Outlook 5
K cant read email or open attachement Using Outlook 0
T Outlook 2013 either fails to mark messages as read or marks them as read, then un-marks them. Using Outlook 1
Mary B VBscript: Need to copy every email to a folder & mark that copy as read Outlook VBA and Custom Forms 5
Mary B Outlook 2013: Rule for copying new email to folder & marking that copy as read Using Outlook 1
M Sorting messages by read/unread status Using Outlook 8
C Mark all incoming emails as read Outlook VBA and Custom Forms 3
A give User Read Only access to secondary mailbox in Exchange 2010 via AD Exchange Server Administration 1
M How do I mark emails already received as read when I get a second, different email based on subject? Outlook VBA and Custom Forms 3
JR Ryan Outlook marks all as "Read" issue Exchange Server Administration 2
T Saving Outlook 2010 email with attachments but read the email without Outlook Using Outlook 2
M Oh please read---> Extracting email web leads on to excel spread sheet Using Outlook 3
S Outlook Custom form - selecting text in read page Using Outlook 0
C In need of VBA code to read / parse HTML - Outlook emails Using Outlook 0
A Can't read my mails if they are on a folder... Using Outlook 0
M Unable to read HTML Using Outlook 2
J Cannot read incoming emails Using Outlook 2
P Custom field is read only Using Outlook 1
C (Read, not read) receipt "subject" problem Using Outlook 8
S iCloud Outlook Calendar is read only Using Outlook 1
Z Mark moved copies as "Read" Using Outlook 19
M Can't read invitations to appointments Using Outlook 1

Similar threads

Back
Top