Following are the properties of the MailItem Object. Each property has been encapsulated in a Function which can be called from your VBA programs. I did not include sample code for each Function.
All you need to do is pass a MailItem object to each Function, and sometimes a second parameter such as a Boolean. How you choose to create the MailItem is up to you. You could use the function to loop through a folder, calling the function on each MailItem present. See TaskItem Properties for sample code you can adapt.
See The MailItem Object for sample code to create NoteItems in several ways.
Actions collection
Function GetMailItemActions(msg As Outlook.MailItem) As Outlook.Actions Set GetMailItemActions = msg.Actions End Function
AlternateRecipientAllowed Property
Function MailAltRecipientAllowed(msg As Outlook.MailItem, Optional altrecipallowed As Variant) As Boolean
' if (boolean) value provided, update existing
If Not IsMissing(altrecipallowed) Then
If CBool(altrecipallowed) Then
msg.AlternateRecipientAllowed = altrecipallowed
End If
End If
' return existing or updated value
MailAltRecipientAllowed = msg.AlternateRecipientAllowed
End FunctionApplication Property
Function GetMailApplication(msg As Outlook.MailItem) As Outlook.Application Set GetMailApplication = msg.Application End Function
Attachments Collection
Function GetMailAttachments(msg As Outlook.MailItem) As Outlook.Attachments Set GetMailAttachments = msg.Attachments End Function
AutoForwarded Property
Function MailAutoForwarded(msg As Outlook.MailItem, Optional autoForwarded As Variant) As Boolean
' if value provided, update existing
If Not IsMissing(autoForwarded) Then
If CBool(autoForwarded) Then
msg.AutoForwarded = autoForwarded
End If
End If
' return updated or existing
MailAutoForwarded = msg.autoForwarded
End FunctionAutoResolvedWinner Property
Function MailAutoResolvedWinner(msg As Outlook.MailItem) As Boolean MailAutoResolvedWinner = ((msg.Conflicts.Count > 0) And (msg.AutoResolvedWinner)) End Function
BCC Property
Function MsgBCC(msg As Outlook.MailItem) As String MsgBCC = msg.BCC End Function
BillingInformation Property
Function MailBillingInfo(msg As Outlook.MailItem, Optional billingInfo As String, _
Optional append As Boolean = False) As String
' set or get msg billing information
If Len(billingInfo) > 0 Then
If append Then
' append value to existing
msg.BillingInformation = msg.BillingInformation & billingInfo
Else
' set value
msg.BillingInformation = billingInfo
End If
End If
' return whether updated or replaced or just checking value
MailBillingInfo = msg.BillingInformation
End FunctionBody Property
Function MailBody(msg As Outlook.MailItem, Optional bodyText As String, _
Optional append As Boolean = False) As String
' set or get Mail body text
If Len(bodyText) > 0 Then
' set body text
If append Then
' add to existing body text
msg.Body = msg.Body & bodyText
Else
' replace with new body text
msg.Body = bodyText
End If
End If
' return body, whether updated or replaced or just checking value
MailBody = msg.body
End FunctionBodyFormat Property
Function MsgBodyFormat(msg As Outlook.MailItem, Optional bodyFormat As Variant) As OlBodyFormat
' if value provided (OlBodyFormat value), update existing
If Not IsMissing(bodyFormat) Then
msg.BodyFormat = bodyFormat
End If
' return existing or updated value
MsgBodyFormat = msg.bodyFormat
End FunctionCategories Property
Function GetMailCategories(msg As Outlook.MailItem) As String GetMailCategories = msg.Categories End Function
CC Property
Use the Recipients Collection to change the CC Recipients.
Function MsgCC(msg As Outlook.MailItem) As String MsgCC = msg.CC End Function
Class Property
Function GetMailClass(msg As Outlook.MailItem) As OlObjectClass GetMailClass = msg.Class End Function
Companies Property
Function MailCompanies(msg As Outlook.MailItem, Optional companyInfo As String, _
Optional append As Boolean = False) As String
' set or get Mail companies string
If Len(companyInfo) > 0 Then
If append Then
' append value to existing
msg.Companies = msg.Companies & companyInfo
Else
' set value
msg.Companies = companyInfo
End If
End If
' return whether updated or replaced or just checking value
MailCompanies = msg.Companies
End FunctionConflicts Property
A message is in conflict if the Conflicts.Count property is greater than zero or the IsConflict Property is True.
Function IsMailInConflict(msg As Outlook.MailItem) As Boolean IsMailInConflict = ((msg.Conflicts.Count > 0) Or (msg.IsConflict)) End Function
Function GetMailConflicts(msg As Outlook.MailItem) As Outlook.Conflicts Set GetMailConflicts = msg.Conflicts End Function
ConversationIndex Property
Function GetmsgCI(msg As Outlook.MailItem) As String GetmsgCI = msg.ConversationIndex End Function
ConversationTopic Property
Function GetmsgCT(msg As Outlook.MailItem) As String GetmsgCT = msg.ConversationTopic End Function
CreationTime Property
Function GetMailCreationTime(msg As Outlook.MailItem) As Date GetMailCreationTime = msg.CreationTime End Function
DeferredDeliveryTime Property
Delay the delivery of your emails with this property. Useful for setting a random delay on your auto-responses, to make your auto-replies look like they are coming from a real person ![]()
Function MsgDeliveryTime(msg As Outlook.MailItem, dte As Date) As Date
' if date provided, update existing value
If dte <> #1/1/4501# Then
msg.DeferredDeliveryTime = dte
End If
' return existing or updated value
MsgDeliveryTime = msg.DeferredDeliveryTime
End FunctionDeleteAfterSubmit Property
Function MailDeleteAfterSubmit(msg As Outlook.MailItem, Optional deleteMsg As Variant) As Boolean
If Not IsMissing(deleteMsg) Then
If CBool(deleteMsg) Then
msg.DeleteAfterSubmit = deleteMsg
End If
End If
MailDeleteAfterSubmit = msg.DeleteAfterSubmit
End FunctionDownloadState Property
Function GetMailDownloadState(msg As Outlook.MailItem) As OlDownloadState GetMailDownloadState = msg.DownloadState End Function
EntryID Property
Function GetMailEntryID(msg As Outlook.MailItem) As String GetMailEntryID = msg.EntryID End Function
ExpiryTime Property
Function MsgExpiryTime(msg As Outlook.MailItem, Optional expirationDate As Variant) As Date
' if expiration date is provided, change existing
If Not IsMissing(expirationDate) Then
If IsDate(expirationDate) Then
msg.ExpiryTime = expirationDate
End If
End If
' return existing or updated expiry time
MsgExpiryTime = msg.ExpiryTime
End FunctionFlagDueBy Property
Function MsgFlagDueBy(msg As Outlook.MailItem, Optional dateDueBy As Variant) As Date
' only valid if FlagStatus property is also set
If MsgFlagStatus(msg) > 0 Then ' it's set
' update existing if value provided
If Not IsMissing(dateDueBy) Then
If IsDate(dateDueBy) Then
msg.FlagDueBy = dateDueBy
End If
End If
End If
' return existing or update value
MsgFlagDueBy = msg.FlagDueBy
End FunctionFlagIcon Property
Function MsgFlagIcon(msg As Outlook.MailItem, Optional flagColor As Variant) As OlFlagIcon
' update if value provided
If Not IsMissing(flagColor) Then
If flagColor < 7 And flagColor > -1 Then
msg.FlagIcon = flagColor
End If
End If
MsgFlagIcon = msg.FlagIcon
End FunctionFlagRequest Property
Function MsgFlagRequest(msg As Outlook.MailItem, Optional requestText As String, _
Optional append As Boolean = False) As String
' only valid if FlagStatus property is also set
If MsgFlagStatus(msg) > 0 Then ' it's set
If Len(requestText) > 0 Then
If append Then
msg.FlagRequest = msg.FlagRequest & requestText
Else
msg.FlagRequest = requestText
End If
End If
End If
' return value, either appended, unchanged or changed
MsgFlagRequest = msg.FlagRequest
End FunctionFlagStatus Property
Function MsgFlagStatus(msg As Outlook.MailItem, Optional flagStatus As Variant) As OlFlagStatus
If Not IsMissing(flagStatus) Then
msg.FlagStatus = flagStatus
End If
MsgFlagStatus = msg.FlagStatus
End FunctionFormDescription Property
Function GetMailFormDescription(msg As Outlook.MailItem) As Outlook.FormDescription Set GetMailFormDescription = msg.FormDescription End Function
GetInspector Property
Function GetMailInspector(msg As Outlook.MailItem) As Outlook.Inspector Set GetMailInspector = msg.GetInspector End Function
HTMLBody Property
Function MsgHTMLBody(msg As Outlook.MailItem, Optional bodyText As String) As String
'The HTMLBody property should be an HTML syntax string.
'Setting the HTMLBody property sets the EditorType property of the item's Inspector to olEditorHTML.
'Setting the HTMLBody property will always update the Body property immediately.
'Outlook blocks code that attempts to access the HTMLBody property for security reasons.
If Len(bodyText) > 0 Then
msg.HTMLBody = bodyText
End If
MsgHTMLBody = msg.HTMLBody
End FunctionImportance Property
Function GetMailImportance(msg As Outlook.MailItem) As OlImportance GetMailImportance = msg.Importance End Function
InternetCodepage Property
Function GetMailICP(msg As Outlook.MailItem) As Long GetMailICP = msg.InternetCodepage End Function
ItemProperties Property
Function GetMailItemProperties(msg As Outlook.MailItem) As Outlook.ItemProperties Set GetMailItemProperties = msg.ItemProperties End Function
LastModificationTime Property
Function GetMailLastModTime(msg As Outlook.MailItem) As Date GetMailLastModTime = msg.LastModificationTime End Function
Links Property
Function GetMailLinks(msg As Outlook.MailItem) As Outlook.Links Set GetMailLinks = msg.Links End Function
MarkForDownload Property
Function MailMarkForDownload(msg As Outlook.MailItem, Optional remoteStatus As OlRemoteStatus) As OlRemoteStatus
' set or get remote status
Select Case remoteStatus
' if remoteStatus is specified, set it for the current MailItem
Case olMarkedForCopy, olMarkedForDelete, olMarkedForDownload, _
olRemoteStatusNone, olUnMarked
msg.MarkForDownload = remoteStatus
MailMarkForDownload = remoteStatus
Case Else
' just return current status
MailMarkForDownload = msg.MarkForDownload
End Select
End FunctionMessageClass Property
Function MailMessageClass(msg As Outlook.MailItem, Optional msgClass As String) As String
' set or get Mail message class
' what are the possible values?
If Len(msgClass) > 0 Then
msg.MessageClass = msgClass
End If
MailMessageClass = msg.MessageClass
End FunctionMileage Property
Function MailMileage(msg As Outlook.MailItem, Optional mileageValue As String, _
Optional append As Boolean = False) As String
' set or get Mail mileage
If Len(mileageValue) > 0 Then
If append Then
msg.Mileage = msg.Mileage & mileageValue
Else
msg.Mileage = mileageValue
End If
End If
' return value, either appended, unchanged or changed
MailMileage = msg.Mileage
End FunctionNoAging Property
Function MailNoAging(msg As Outlook.MailItem, Optional ageItem As Variant) As Boolean
' if value provided, update existing
If Not IsMissing(ageItem) Then
If CBool(ageItem) Then
msg.NoAging = ageItem
End If
End If
' return existing or updated value
MailNoAging = msg.NoAging
End FunctionOriginatorDeliveryReportRequested Property
Function MsgDeliveryReport(msg As Outlook.MailItem, _
Optional deliveryReport As Variant) As Boolean
' if value provided, update existing
If Not IsMissing(deliveryReport) Then
If CBool(deliveryReport) Then
msg.OriginatorDeliveryReportRequested = deliveryReport
End If
End If
' return existing or updated value
MsgDeliveryReport = msg.OriginatorDeliveryReportRequested
End FunctionOutlookInternalVersion Property
Function MailInternalVersion(msg As Outlook.MailItem) As Long MailInternalVersion = msg.OutlookInternalVersion End Function
OutlookVersion Property
Function MailOutlookVersion(msg As Outlook.MailItem) As String MailOutlookVersion = msg.OutlookVersion End Function
Parent Property
Function GetMailParent(msg As Outlook.MailItem) As Object Set GetMailParent = msg.Parent End Function
Permission Property
Function MsgPermission(msg As Outlook.MailItem, Optional perm As Variant) As OlPermission
' if value provided, update existing
If Not IsMissing(perm) Then
msg.Permission = perm
End If
' return existing or updated value
MsgPermission = msg.Permission
End FunctionPermissionService Property
Function MsgPermissionService(msg As Outlook.MailItem, Optional serviceName As Variant) As OlPermissionService
If Not IsMissing(serviceName) Then
msg.PermissionService = serviceName
End If
MsgPermissionService = msg.PermissionService
End FunctionReadReceiptRequested Property
Function MsgReadReceipt(msg As Outlook.MailItem, _
Optional readReceiptRequested As Variant) As Boolean
' read-only for sent emails
If Not msg.Sent Then
If Not IsMissing(readReceiptRequested) Then
msg.ReadReceiptRequested = readReceiptRequested
End If
End If
MsgReadReceipt = msg.ReadReceiptRequested
End FunctionReceivedByEntryID Property
Function GetMsgReceivedByEntryID(msg As Outlook.MailItem) As String GetMsgReceivedByEntryID = msg.ReceivedByEntryID End Function
ReceivedByName Property
Function GetMsgReceivedByName(msg As Outlook.MailItem) As String GetMsgReceivedByName = msg.ReceivedByName End Function
ReceivedOnBehalfOfEntryID Property
Function GetMsgReceivedOnBehalfOfEntryID(msg As Outlook.MailItem) As String GetMsgReceivedOnBehalfOfEntryID = msg.ReceivedOnBehalfOfEntryID End Function
ReceivedOnBehalfOfName Property
Function GetMsgReceivedOnBehalfOgName(msg As Outlook.MailItem) As String GetMsgReceivedOnBehalfOgName = msg.ReceivedOnBehalfOfName End Function
ReceivedTime Property
Function GetMsgReceivedTime(msg As Outlook.MailItem) As Date GetMsgReceivedTime = msg.ReceivedTime End Function
RecipientReassignmentProhibited Property
Function MsgRecipientCannotForward(msg As Outlook.MailItem, _
Optional cannotForward As Variant) As Boolean
If Not IsMissing(cannotForward) Then
If CBool(cannotForward) Then
msg.RecipientReassignmentProhibited = cannotForward
End If
End If
MsgRecipientCannotForward = msg.RecipientReassignmentProhibited
End FunctionRecipients Property
Function GetMailRecipients(msg As Outlook.MailItem) As Outlook.Recipients Set GetMailRecipients = msg.Recipients End Function
ReminderOverrideDefault Property
Function MsgReminderOverrideDefault(msg As Outlook.MailItem, Optional override As Variant) As Boolean
' get or set ReminderOverrideDefault
If Not IsMissing(override) Then
If CBool(override) Then
msg.ReminderOverrideDefault = override
End If
End If
MsgReminderOverrideDefault = msg.ReminderOverrideDefault
End FunctionReminderPlaySound Property
Function MsgReminderPlaySound(msg As Outlook.MailItem, Optional playSound As Variant) As Boolean
' get or set ReminderPlaySound
If Not IsMissing(playSound) Then
If CBool(playSound) Then
msg.ReminderPlaySound = playSound
End If
End If
MsgReminderPlaySound = msg.ReminderPlaySound
End FunctionReminderSet Property
Function MsgReminderSet(msg As Outlook.MailItem, Optional setReminder As Variant) As Boolean
' get or set ReminderSet
If Not IsMissing(setReminder) Then
If CBool(setReminder) Then
msg.ReminderSet = setReminder
End If
End If
MsgReminderSet = msg.ReminderSet
End FunctionReminderSoundFile Property
Function MailReminderSoundFile(msg As Outlook.MailItem, Optional filePath As String) As String
' get or set reminder sound file path
If Len(filePath) > 0 Then
' make sure filepath is valid
If Len(Dir(filePath)) > 0 Then
' set filepath
msg.ReminderSoundFile = filePath
End If
End If
' return filepath
MailReminderSoundFile = msg.ReminderSoundFile
End FunctionReminderTime Property
Function MailReminderTime(msg As Outlook.MailItem, Optional dteReminder As Variant) As Date
' get or set reminder time
If Not IsMissing(dteReminder) Then
If CDate(dteReminder) Then
If dteReminder <> #1/1/4501# Then ' it was specified
msg.ReminderTime = dteReminder
End If
End If
End If
MailReminderTime = msg.ReminderTime
End FunctionRemoteStatus Property
Function MsgRemoteStatus(msg As Outlook.MailItem, Optional remoteStatus As Variant) As OlRemoteStatus
If Not IsMissing(remoteStatus) Then
msg.RemoteStatus = remoteStatus
End If
MsgRemoteStatus = msg.remoteStatus
End FunctionReplyRecipientNames Property
Function GetMsgReplyRecipientNames(msg As Outlook.MailItem) As String GetMsgReplyRecipientNames = msg.ReplyRecipientNames End Function
ReplyRecipients Property
Function GetMsgReplyRecipients(msg As Outlook.MailItem) As Outlook.Recipients ' Outlook blocks code that attempts to access the ReplyRecipients ' property for security reasons. Set GetMsgReplyRecipients = msg.ReplyRecipients End Function
Saved Property
Function GetMsgSaved(msg As Outlook.MailItem) As Boolean GetMsgSaved = msg.Saved End Function
SaveSentMessageFolder Property
Function MsgSentMessageFolder(msg As Outlook.MailItem, folder As Variant) As Outlook.MAPIFolder
' folder can be a MAPIFolder Object or a string representing a full folder path
Dim tempFolder As Outlook.MAPIFolder
If Not IsMissing(folder) Then
Select Case TypeName(folder)
Case "MAPIFolder"
Set msg.SaveSentMessageFolder = folder
Case "String"
Set tempFolder = folder
Set msg.SaveSentMessageFolder = folder
End Select
End If
Set MsgSentMessageFolder = msg.SaveSentMessageFolder
End FunctionSenderEmailAddress Property
Function GetMsgSenderEmail(msg As Outlook.MailItem) As String GetMsgSenderEmail = msg.SenderEmailAddress End Function
SenderEmailType Property
Function GetMsgSenderType(msg As Outlook.MailItem) As String GetMsgSenderType = msg.SenderEmailType End Function
SenderName Property
Function GetMsgSenderName(msg As Outlook.MailItem) As String GetMsgSenderName = msg.SenderName End Function
Sensitivity Property
Function MailSensitivity(msg As Outlook.MailItem, Optional sens As Variant) As OlSensitivity
' get or set Mail sensitivity
If Not IsMissing(sens) Then
msg.Sensitivity = sens
End If
MailSensitivity = msg.Sensitivity
End FunctionSent Property
Function MsgSent(msg As Outlook.MailItem) As Boolean MsgSent = msg.Sent End Function
SentOn Properrty
Function GetMsgSentDate(msg As Outlook.MailItem) As Date GetMsgSentDate = msg.SentOn End Function
SentOnBehalfOfName Property
Function MsgSentOnBehalfOfName(msg As Outlook.MailItem, _
Optional Name As String) As String
If Len(Name) > 0 Then
msg.SentOnBehalfOfName = Name
End If
MsgSentOnBehalfOfName = msg.SentOnBehalfOfName
End FunctionSession Property
Function GetMsgSession(msg As Outlook.MailItem) As Outlook.NameSpace Set GetMsgSession = msg.Session End Function
Size Property
Function GetMsgSize(msg As Outlook.MailItem) As Long GetMsgSize = msg.Size End Function
Subject Property
Function MsgSubject(msg As Outlook.MailItem) As String MsgSubject = msg.Subject End Function
Submitted Property
Function GetMsgSubmitted(msg As Outlook.MailItem) As Boolean GetMsgSubmitted = msg.Submitted End Function
To Property
This function returns the To value for a given message; use the Recipients Collection to edit recipients.
Function GetMsgTo(msg As Outlook.MailItem) As String GetMsgTo = msg.To End Function
Unread Property
Function MsgUnread(msg As Outlook.MailItem, Optional isUnread As Variant) As Boolean
' update existing if value provided
If Not IsMissing(isUnread) Then
If CBool(isUnread) Then
msg.Unread = isUnread
End If
End If
' return existing or updated unread status
MsgUnread = msg.Unread
End FunctionUserProperties Property/Collection
Function GetMailUserProperties(msg As Outlook.MailItem) As Outlook.UserProperties Set GetMailUserProperties = msg.UserProperties End Function
VotingOptions Property
Function MsgVotingOptions(msg As Outlook.MailItem, _
Optional votingOptions As String) As String
If Len(votingOptions) > 0 Then
msg.votingOptions = votingOptions
End If
MsgVotingOptions = msg.VotingOptions
End FunctionVotingResponse Property
Function MsgVotingResponse(msg As Outlook.MailItem, _
Optional vr As String) As String
If Len(vr) > 0 Then
msg.VotingResponse = vr
End If
MsgVotingResponse = msg.VotingResponse
End Function