Setting the Reminder flag in VBA for e-Mails sent to users

Status
Not open for further replies.
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
 
S

Sue Mosher [MVP]

Is this supposed to be Outlook VBA code? In what version of Outlook?

Sue Mosher

"Deggsie" <Deggsie> wrote in message

news:4277A49D-6BDB-4B2E-9EA6-2311DA44C15B@microsoft.com...
> 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
 
J

JP

Have you tried stepping through the code to see if the reminder/flag

is being set on the email?

Why aren't you setting the MailItem.ReminderTime property?

Why is vFlagDueBy a Variant (not Date) type?

If nothing works, my guess would be that (just like Tasks) you can't

set a reminder on someone else's computer.

--JP

On Feb 10, 5:34 am, Deggsie <Degg...> wrote:
> 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
 
D

Deggsie

Hi,

Sorry, forgot to mention: Outlook version 2007

"Sue Mosher [MVP]" wrote:


> Is this supposed to be Outlook VBA code? In what version of Outlook?
> > Sue Mosher
> > >

> "Deggsie" <Deggsie> wrote in message
> news:4277A49D-6BDB-4B2E-9EA6-2311DA44C15B@microsoft.com...
> > 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


> .
>
 
D

Deggsie

Hi JP,


> Have you tried stepping through the code to see if the reminder/flag
> is being set on the email?


Yup, and it's being set.


> Why aren't you setting the MailItem.ReminderTime property?


I am doing now.


> Why is vFlagDueBy a Variant (not Date) type?


It didn't make a difference either way as I'm passing a date into this

parameter anyway.


> If nothing works, my guess would be that (just like Tasks) you can't
> set a reminder on someone else's computer.


And that could be the issue all along.

I've been working with Tasks as well, but my issue with those was that I

couldn't avoid the task being created on my machine before it was 'allocated'

to someone else. Which also led to me getting updates on when the task was

closed, etc.

The reason I need this task/e-Mail thing to work is that the 'system issues'

are raised by one individual and then passed to recipients to deal with. The

recipient's boss is also notified that the recipient has an outstanding job

and the target date for completion (less two days) is what I was hoping to

use for the reminder flag.

Thanks for your suggestions anyway.
 
S

Sue Mosher [MVP]

When I ran your code, the message arrived with a flag but no reminder. I

think it's by design that it doesn't carry a reminder. Early versions of

Outlook could do that -- make a reminder fire on a recipient's machine

which offered the potential for an annoying of spam and other intrusiveness.

Now, it's up to users to decide when to set a reminder.

Sue Mosher

"Deggsie" <Deggsie> wrote in message

news:640E6B9B-9B33-47B3-B63E-548B4BF67DD2@microsoft.com...


> Sorry, forgot to mention: Outlook version 2007



> > > 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

>

>
>> .
> >
 
Status
Not open for further replies.
Top