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.
Similar threads
Thread starter Title Forum Replies Date
Diane Poremsky Setting Custom Reminder Times New Slipstick.com Articles 0
E Need Help on Setting up a repeated Reminder on Task with Reoccurence Every Year Using Outlook 6
e_a_g_l_e_p_i Outlook 2010 Help setting up Gmail account in Outlook 2010 Using Outlook 3
P OWA Settings->Calendar->Events from Email; Setting changes do not hold Using Outlook 1
Marc2019 Setting up an Outlook Account on Mac Os 10.6.8 Outlook 2011 Using Outlook 1
L Outlook Office 365 client: won't remember my setting File, not to collapse ribbon Using Outlook 2
M Where is the setting to *turn off* open calendar in a new window? Using Outlook 3
llama_thumper Setting up forwarders on Exchange server Exchange Server Administration 0
B Setting rules Using Outlook 1
C iCloud Setting missing Outlook tab and Outlook missing the iCloud refresh button Using Outlook 4
B Setting defaults Using Outlook 2
C need help setting up outlook first time Using Outlook 1
P Reading Pane (Reading Pain?) Default Setting Using Outlook 1
W Setting up a custom form Outlook VBA and Custom Forms 2
mctabish Setting "Reply To" based on inbox Outlook VBA and Custom Forms 2
R Setting font and color used when replying to an email Outlook VBA and Custom Forms 3
M Setting flag follow up for next business day Outlook VBA and Custom Forms 1
Ed Sheehan Unusual behaviour in setting Sender (Outlook 2016) Outlook VBA and Custom Forms 4
Jennifer Murphy Equations don't comply with style setting to left justify Using Outlook 0
J Setting default address book Using Outlook 0
N Does a Shared Folder Policy override a Digital Signature Setting for macros? Outlook VBA and Custom Forms 6
Diane Poremsky Setting up an Outlook.com IMAP account New Slipstick.com Articles 0
Diane Poremsky Setting the default Country for Outlook Contacts New Slipstick.com Articles 0
H Need help setting up GetFolderPath-Makro with Vodafone IMAP Mail-Account Outlook VBA and Custom Forms 0
Diane Poremsky Adjusting Outlook's Zoom setting in Email New Slipstick.com Articles 0
O Setting default format for composing/replying to emails Using Outlook 3
B Outlook Calendar/setting appointments Using Outlook 1
Diane Poremsky Adjusting Outlook's Zoom setting in Email New Slipstick.com Articles 0
A Can't stop Outlook.com from setting reminders on appointments? Using Outlook.com accounts in Outlook 3
A Setting RULES with more than one condition in MS OUTLOOK Using Outlook 6
L Setting up my PA's Outlook Using Outlook 7
N "Instant Search" setting a default view Using Outlook 3
H SETTING UP A "NEW" NEVER HAD NEVER USED EMAIL ACCOUNT Using Outlook 9
K Setting Default Email Address for Meeting Replies Using Outlook 3
S Setting up Outlook 2010 to work with custom domain outlook.com account BCM (Business Contact Manager) 3
D Setting defult "Show a room list" Using Outlook 0
Horsepower Setting appointments in calendar Using Outlook 3
J Setting tabs in contacts / notes field Using Outlook 0
T Setting a Default Subject from a certain Signature Using Outlook 0
K Help Needed - setting up Email in Outlook 2013 Using Outlook 3
mikecox setting Default area code in Contacts Using Outlook 5
G Outlook2013 - "From" name doesn't change even when changed in Account Setting Using Outlook 4
D How do I start completely from scratch in setting up Outlook 2013? Using Outlook 6
V View zoom setting changing Using Outlook 1
C Setting up Outlook 10 on Widows 8 using Google Server Using Outlook 3
I Outlook Appointments - Setting default text in message body Using Outlook 3
T Setting Color codes for each user of a shared Calendar Using Outlook 1
J setting date in drafts Using Outlook 4
J Outlook 2010 - email address disappears when setting up new contact Using Outlook 0
V Setting up Outlook 2013 for AOL (POP3) Account Using Outlook 16

Similar threads

Top