.NET: Get all Outlook calendar items

I’ve studied the docs and this is my result: I’ve put a time limit of one month hard-coded, but this is just an example. public void GetAllCalendarItems() { Microsoft.Office.Interop.Outlook.Application oApp = null; Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null; Microsoft.Office.Interop.Outlook.MAPIFolder CalendarFolder = null; Microsoft.Office.Interop.Outlook.Items outlookCalendarItems = null; oApp = new Microsoft.Office.Interop.Outlook.Application(); mapiNamespace = oApp.GetNamespace(“MAPI”); ; CalendarFolder = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar); … Read more

CSS padding is not working as expected in Outlook

Unfortunately, when it comes to EDMs (Electronic Direct Mail), Outlook is your worst enemy. Some versions don’t respect padding when a cell’s content dictates the cell dimensions. The approach that’ll give you the most consistent result across mail clients is to use empty table cells as padding (I know, the horror), but remember to fill … Read more

How to insert text into Outlook email editor using VBA

InsertBefore Method or InsertAfter Method Inspector.WordEditor Property (Outlook) Application.ActiveInspector Method (Outlook) Example Option Explicit Public Sub Example() Dim Inspector As Outlook.Inspector Dim wdDoc As Word.Document Dim Selection As Word.Selection Set Inspector = Application.ActiveInspector() Set wdDoc = Inspector.WordEditor Set Selection = wdDoc.Application.Selection Selection.InsertBefore Format(Now, “DD/MM/YYYY”) Set Inspector = Nothing Set wdDoc = Nothing Set Selection = … Read more

Distinguish visible and invisible attachments with Outlook VBA

As I can test so far, an embedded attachment always have a MIME content ID, regardless whether it appears in the mail body. So the solution is to check whether it has a content ID. Here is an example code that counts the visible attachments: Sub ShowVisibleAttachmentCount() Const PR_ATTACH_CONTENT_ID As String = “http://schemas.microsoft.com/mapi/proptag/0x3712001F” Const PR_ATTACHMENT_HIDDEN … Read more