Code Samples

This category contains code samples put together to solve a specific user’s problem.

Always open Contacts to a specific contacts folder

Always open Contacts to a specific contacts folder

Use a VBA macro to always open a specific folder when you switch to a module.

Use a default subject for New messages

Use a default subject for New messages

How to use a VBA macro to insert a predefined text into the subject field of a new messages. Method works with any Outlook item type.

Monitor secondary mailbox folder for new messages

Use a VBA macro to monitor a folder in a secondary mailbox for new messages.

Paste clipboard contents using VBA

Although Outlook VBA doesn't include a paste from clipboard function directly, you can use the MSForms dataobject to transfer the clipboard contents to a string which is then called from VBA.

Create a Task when a message is flagged

Create a Task when a message is flagged

Use the ItemChange event to run a macro when an Outlook item is changed. In this example, a task is created when the Quick Click Flag is clicked.

VBA UserForm sample: Select from a list of templates

VBA UserForm sample: Select from a list of templates

How to use a userform and VBA to select from a list of templates when creating a new message to a contact.

Delete attachments from messages

How to keep the name of an attachment in a message after using VBA to remove the attachment.

Automatically create a task when sending a message

Automatically create a task when sending a message

How to automatically create tasks for message you send using a VBA macro.

How to set a flag to follow up using VBA

How to set a flag to follow up using VBA

You can edit the Flag to Follow up field text each time you flag a message, but you can't save the changes permanently, or even temporarily in an MRU list. However, you can use VBA to set flags, which will allow you to save custom Flag to text, as well as custom reminder times and start or due dates.

Export (save) Outlook Contact photos

Export (save) Outlook Contact photos

Use VBA to export a photo from a contact and save it to the hard drive. Use a second macro to add the photo to a new contact.