MailItem Properties
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
Set GetMailItemActions = msg.Actions
End Function
AlternateRecipientAllowed Property
' 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 Function
Application Property
Set GetMailApplication = msg.Application
End Function
Attachments Collection
Set GetMailAttachments = msg.Attachments
End Function
AutoForwarded Property
' 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 Function
AutoResolvedWinner Property
MailAutoResolvedWinner = ((msg.Conflicts.Count > 0) And (msg.AutoResolvedWinner))
End Function
BCC Property
MsgBCC = msg.BCC
End Function
BillingInformation Property
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 Function
Body Property
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 Function
BodyFormat Property
' 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 Function
Categories Property
GetMailCategories = msg.Categories
End Function
CC Property
Use the Recipients Collection to change the CC Recipients.
MsgCC = msg.CC
End Function
Class Property
GetMailClass = msg.Class
End Function
Companies Property
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 Function
Conflicts Property
A message is in conflict if the Conflicts.Count property is greater than zero or the IsConflict Property is True.
IsMailInConflict = ((msg.Conflicts.Count > 0) Or (msg.IsConflict))
End Function
Set GetMailConflicts = msg.Conflicts
End Function
ConversationIndex Property
GetmsgCI = msg.ConversationIndex
End Function
ConversationTopic Property
GetmsgCT = msg.ConversationTopic
End Function
CreationTime Property
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
' 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 Function
DeleteAfterSubmit Property
If Not IsMissing(deleteMsg) Then
If CBool(deleteMsg) Then
msg.DeleteAfterSubmit = deleteMsg
End If
End If
MailDeleteAfterSubmit = msg.DeleteAfterSubmit
End Function
DownloadState Property
GetMailDownloadState = msg.DownloadState
End Function
EntryID Property
GetMailEntryID = msg.EntryID
End Function
ExpiryTime Property
' 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 Function
FlagDueBy Property
' 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 Function
FlagIcon Property
' 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 Function
FlagRequest Property
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 Function
FlagStatus Property
If Not IsMissing(flagStatus) Then
msg.FlagStatus = flagStatus
End If
MsgFlagStatus = msg.FlagStatus
End Function
FormDescription Property
Set GetMailFormDescription = msg.FormDescription
End Function
GetInspector Property
Set GetMailInspector = msg.GetInspector
End Function
HTMLBody Property
'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 Function
Importance Property
GetMailImportance = msg.Importance
End Function
InternetCodepage Property
GetMailICP = msg.InternetCodepage
End Function
ItemProperties Property
Set GetMailItemProperties = msg.ItemProperties
End Function
LastModificationTime Property
GetMailLastModTime = msg.LastModificationTime
End Function
Links Property
Set GetMailLinks = msg.Links
End Function
MarkForDownload Property
' 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 Function
MessageClass Property
' 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 Function
Mileage Property
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 Function
NoAging Property
' 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 Function
OriginatorDeliveryReportRequested Property
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 Function
OutlookInternalVersion Property
MailInternalVersion = msg.OutlookInternalVersion
End Function
OutlookVersion Property
MailOutlookVersion = msg.OutlookVersion
End Function
Parent Property
Set GetMailParent = msg.Parent
End Function
Permission Property
' if value provided, update existing
If Not IsMissing(perm) Then
msg.Permission = perm
End If
' return existing or updated value
MsgPermission = msg.Permission
End Function
PermissionService Property
If Not IsMissing(serviceName) Then
msg.PermissionService = serviceName
End If
MsgPermissionService = msg.PermissionService
End Function
ReadReceiptRequested Property
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 Function
ReceivedByEntryID Property
GetMsgReceivedByEntryID = msg.ReceivedByEntryID
End Function
ReceivedByName Property
GetMsgReceivedByName = msg.ReceivedByName
End Function
ReceivedOnBehalfOfEntryID Property
GetMsgReceivedOnBehalfOfEntryID = msg.ReceivedOnBehalfOfEntryID
End Function
ReceivedOnBehalfOfName Property
GetMsgReceivedOnBehalfOgName = msg.ReceivedOnBehalfOfName
End Function
ReceivedTime Property
GetMsgReceivedTime = msg.ReceivedTime
End Function
RecipientReassignmentProhibited Property
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 Function
Recipients Property
Set GetMailRecipients = msg.Recipients
End Function
ReminderOverrideDefault Property
' get or set ReminderOverrideDefault
If Not IsMissing(override) Then
If CBool(override) Then
msg.ReminderOverrideDefault = override
End If
End If
MsgReminderOverrideDefault = msg.ReminderOverrideDefault
End Function
ReminderPlaySound Property
' get or set ReminderPlaySound
If Not IsMissing(playSound) Then
If CBool(playSound) Then
msg.ReminderPlaySound = playSound
End If
End If
MsgReminderPlaySound = msg.ReminderPlaySound
End Function
ReminderSet Property
' get or set ReminderSet
If Not IsMissing(setReminder) Then
If CBool(setReminder) Then
msg.ReminderSet = setReminder
End If
End If
MsgReminderSet = msg.ReminderSet
End Function
ReminderSoundFile Property
' 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 Function
ReminderTime Property
' 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 Function
RemoteStatus Property
If Not IsMissing(remoteStatus) Then
msg.RemoteStatus = remoteStatus
End If
MsgRemoteStatus = msg.remoteStatus
End Function
ReplyRecipientNames Property
GetMsgReplyRecipientNames = msg.ReplyRecipientNames
End Function
ReplyRecipients Property
' Outlook blocks code that attempts to access the ReplyRecipients
' property for security reasons.
Set GetMsgReplyRecipients = msg.ReplyRecipients
End Function
Saved Property
GetMsgSaved = msg.Saved
End Function
SaveSentMessageFolder Property
' 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 Function
SenderEmailAddress Property
GetMsgSenderEmail = msg.SenderEmailAddress
End Function
SenderEmailType Property
GetMsgSenderType = msg.SenderEmailType
End Function
SenderName Property
GetMsgSenderName = msg.SenderName
End Function
Sensitivity Property
' get or set Mail sensitivity
If Not IsMissing(sens) Then
msg.Sensitivity = sens
End If
MailSensitivity = msg.Sensitivity
End Function
Sent Property
MsgSent = msg.Sent
End Function
SentOn Properrty
GetMsgSentDate = msg.SentOn
End Function
SentOnBehalfOfName Property
Optional Name As String) As String
If Len(Name) > 0 Then
msg.SentOnBehalfOfName = Name
End If
MsgSentOnBehalfOfName = msg.SentOnBehalfOfName
End Function
Session Property
Set GetMsgSession = msg.Session
End Function
Size Property
GetMsgSize = msg.Size
End Function
Subject Property
MsgSubject = msg.Subject
End Function
Submitted Property
GetMsgSubmitted = msg.Submitted
End Function
To Property
This function returns the To value for a given message; use the Recipients Collection to edit recipients.
GetMsgTo = msg.To
End Function
Unread Property
' 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 Function
UserProperties Property/Collection
Set GetMailUserProperties = msg.UserProperties
End Function
VotingOptions Property
Optional votingOptions As String) As String
If Len(votingOptions) > 0 Then
msg.votingOptions = votingOptions
End If
MsgVotingOptions = msg.VotingOptions
End Function
VotingResponse Property
Optional vr As String) As String
If Len(vr) > 0 Then
msg.VotingResponse = vr
End If
MsgVotingResponse = msg.VotingResponse
End Function