Outlook macro

SAldrich

New Member
Joined
Sep 29, 2008
Messages
15
Hello all,
I know this is going a little off topic, but does anyone know if I can create a macro in Outlook that would make a change (add details) to emails received into a specific folder? (even if you don't know, if you could point me in the right direction that would be a great help!)

Many thanks all,
Sinead
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
yes it's possible but it could be tricky given you intend to run on a new mail event where the new mail will be posted to a folder (other than Inbox) -- ie Rules Wizard in place... and you would only want to process this one mail message in this folder as opposed to all of them as and when new mail is received... is all of that correct ?

Updating messages etc is no biggy... a small example below would update all messages in these folders with the text "Updated " and current time... equally trapping new mail is relatively straightforward with Outlook NewMail event but this will fire before the message is moved by your rules ... ie applied at Application level not individual mail folder level...

I think we would probably need to understand the rules that govern whether or not the new mail message needs to be updated -- ie conforms to the Rules that will push it into the relevant folder.... the below is an illustration of how you can update messages etc... I don't think this is viable in your case ... I think all needs to be coded within newmail event but we need to know how to differentiate between new messages in terms of which should be updated (ie mimic your rules wizard conditions)

Code:
Sub UPDATEMYMAIL()
Dim oNS As NameSpace
Dim oFL As Outlook.MAPIFolder
Dim oMI As MailItem
Set oNS = Outlook.GetNamespace("MAPI")
Set oFL = oNS.Folders("Personal Folders").Folders("Main Folder").Folders("Sub Folder")
For Each oMI In oFL.Items
    oMI.Body = oMI.Body & vbCrLf & "Updated " & Now
    oMI.Save
Next oMI
Set oFL = Nothing
Set oNS = Nothing
End Sub

The above can of course be invoked by the NewMail event, eg:

Code:
Private Sub Application_NewMail()
DoEvents
Call UPDATEMYMAIL
End Sub

But the key is you're not going to want to fire this against all messages in the folder every time new mail is pushed into it... so we need more info.
 
Upvote 0
Many thanks for that! Its given something to work with so I'll have a think about how to proceed. May be posting again when we decide how to proceed.

Thank you!!
 
Upvote 0

Forum statistics

Threads
1,225,377
Messages
6,184,618
Members
453,249
Latest member
gmazee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top