Posts

Showing posts with the label VBA

Macros to send all emails from Drafts folder at once in Outlook

There is sometimes a need to send all draft emails at once. To do this: Start Outlook and choose Tools, Macro, Visual Basic Editor (or press Alt+F11) to open the VBA Editor. In the Project window, select Project1 and expand the tree until you see ThisOutlookSession. Select ThisOutlookSession and press F7 to open the Code window. Enter the following in the Code window: Public Sub SendDrafts() Dim lDraftItem As Long Dim myOutlook As Outlook.Application Dim myNameSpace As Outlook.NameSpace Dim myFolders As Outlook.Folders Dim myDraftsFolder As Outlook.MAPIFolder 'Send all items in the "Drafts" folder that have a "To" address filled in. 'Setup Outlook Set myOutlook = Outlook.Application Set myNameSpace = myOutlook.GetNamespace("MAPI") Set myFolders = myNameSpace.Folders 'Set Draft Folder. This will need modification based on where it's being run. Set myDraftsFolder = myFolders("Personal Folders").Folders(...

VBA script to modify all Outlook Calendar items

Using the script below you may automate the process of putting birthdays in your calendar. This is the 2 step process. First - you import your birthdays list from .xls file to Outlook calendar and second - you run the script to make all appointments to be recurring. So this script will modify all (multiple) Outlook Calendar items to be rucurring yearly: Sub replacement()  Dim Ns As NameSpace  Dim MyCalendar As MAPIFolder  Dim Item As Object  Set Ns = GetNamespace("MAPI")  Set MyCalendar = Ns.GetDefaultFolder(olFolderCalendar)  Set srtitems = MyCalendar.Items     For Each Item In srtitems  DoEvents    Set myRecurrPatt = Item.GetRecurrencePattern     myRecurrPatt.RecurrenceType = olRecursYearly     Item.Save  Next End Sub