D
Deggsie
I'm trying to programmatically send an e-Mail to a given recipient and set
the Follow-Up and Reminder flag to remind the recipient to deal with the
e-Mail by a certain date.
I've trawled the web for how-to's and got a function working, but it simply
isn't setting the reminder flag on the e-Mail.
The function I wrote allows me to pass various parameters and, based on
whether or not the mail is to be flagged for follow-up, flags the mail.
Code is attached below. If anyone can help me out, I'd appreciate it.
Public Sub SendMail(sTo As String, sCC As String, sBCC As String, sSubject
As String, sBody As String, iImportance As Integer, bSetFlag As Boolean,
vFlagDueBy As Variant, bViewMsg As Boolean)
Dim strBodyText As String, vDate As Variant
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim olMailItem As Outlook.MailItem
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olFolder = olNS.GetDefaultFolder(olFolderInbox)
Set olMailItem = olFolder.Items.Add("IPM.Note")
' Set olMailItem = Item
With olMailItem
.To = sTo
.CC = sCC
.BCC = sBCC
.Subject = sSubject
.Body = sBody
.Importance = iImportance
Select Case bSetFlag
Case True
.FlagStatus = olFlagMarked
.FlagIcon = olRedFlagIcon
.FlagDueBy = vFlagDueBy
.ReminderOverrideDefault = True
.ReminderSet = True
End Select
Select Case bViewMsg
Case True
.Display ' shows e-Mail to the user for confirmation/editing
Case Else
.Save
.Send ' send the e-Mail without user interaction
End Select
End With
Set olMailItem = Nothing
Set olFolder = Nothing
Set olNS = Nothing
Set olApp = Nothing
End Sub
the Follow-Up and Reminder flag to remind the recipient to deal with the
e-Mail by a certain date.
I've trawled the web for how-to's and got a function working, but it simply
isn't setting the reminder flag on the e-Mail.
The function I wrote allows me to pass various parameters and, based on
whether or not the mail is to be flagged for follow-up, flags the mail.
Code is attached below. If anyone can help me out, I'd appreciate it.
Public Sub SendMail(sTo As String, sCC As String, sBCC As String, sSubject
As String, sBody As String, iImportance As Integer, bSetFlag As Boolean,
vFlagDueBy As Variant, bViewMsg As Boolean)
Dim strBodyText As String, vDate As Variant
Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olFolder As Outlook.MAPIFolder
Dim olMailItem As Outlook.MailItem
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olFolder = olNS.GetDefaultFolder(olFolderInbox)
Set olMailItem = olFolder.Items.Add("IPM.Note")
' Set olMailItem = Item
With olMailItem
.To = sTo
.CC = sCC
.BCC = sBCC
.Subject = sSubject
.Body = sBody
.Importance = iImportance
Select Case bSetFlag
Case True
.FlagStatus = olFlagMarked
.FlagIcon = olRedFlagIcon
.FlagDueBy = vFlagDueBy
.ReminderOverrideDefault = True
.ReminderSet = True
End Select
Select Case bViewMsg
Case True
.Display ' shows e-Mail to the user for confirmation/editing
Case Else
.Save
.Send ' send the e-Mail without user interaction
End Select
End With
Set olMailItem = Nothing
Set olFolder = Nothing
Set olNS = Nothing
Set olApp = Nothing
End Sub