MadeofStone
03-06-2015, 09:46 AM
Hi,
I have simple script set up to run as part of a rule against all incoming messages. The script basically checks if the mail has an attachment and if the mail is bigger than 1MB. If these conditions are true then an expiry date is set equal to the date the mail item was created + 30 days. Code below:-
Sub SetExpire(item As Outlook.MailItem)
If item.Attachments.Count > 0 And item.Size > 1048576 Then 'checks if e-mail has an attachment and checks if e-mail size if greater that 1MB (expressed in Bytes)
item.ExpiryTime = item.CreationTime + 30 'sets expiry date as 30 days from date the mail item was created
item.Save 'saves the e-mail with expiry date set
End If
End Sub
How can I tweak this code so Outlook recognises the macro in the Developer tab allowing me to assign it to a custom button in a new tab on the ribbon? I would then like the macro to run for all mail items in the Sent Items and Deleted items folders
Help would be greatly appreciated.
Cheers
I have simple script set up to run as part of a rule against all incoming messages. The script basically checks if the mail has an attachment and if the mail is bigger than 1MB. If these conditions are true then an expiry date is set equal to the date the mail item was created + 30 days. Code below:-
Sub SetExpire(item As Outlook.MailItem)
If item.Attachments.Count > 0 And item.Size > 1048576 Then 'checks if e-mail has an attachment and checks if e-mail size if greater that 1MB (expressed in Bytes)
item.ExpiryTime = item.CreationTime + 30 'sets expiry date as 30 days from date the mail item was created
item.Save 'saves the e-mail with expiry date set
End If
End Sub
How can I tweak this code so Outlook recognises the macro in the Developer tab allowing me to assign it to a custom button in a new tab on the ribbon? I would then like the macro to run for all mail items in the Sent Items and Deleted items folders
Help would be greatly appreciated.
Cheers