How to set a flag to follow up using VBA - for addressee in TO field

Status
Not open for further replies.
Outlook version
Outlook 365 64 bit
Email Account
Exchange Server
Hi,

i have embedded this macro :

Public Sub SetCustomFlag()

Dim objMsg As Object

Set objMsg = GetCurrentItem()

With objMsg

' due this week flag
.MarkAsTask olMarkThisWeek
' sets a specific due date
.TaskDueDate = Now + 3

.FlagRequest = "Call " & objMsg.SenderName
.ReminderSet = True
.ReminderTime = Now + 2
.Save
End With

Set objMsg = Nothing
End Sub

from : How to set a flag to follow up using VBA
with some tweaks and seems to be working fine on outlook 2016 / o365 with exchange - thanks

the one thing I would love to have is to have this flag/reminder request sent, instead of all recipients to people in the TO field only.
(people in cc and bcc should not get the flag/reminder)

Is there a way to handle that?

appreciate any inputs

jf
 
hello Diane,

hope you are well and thanks for coming back!

the point of macroing this is to slipstream the admin of this flagging (1 click vs many).
I only need one type of flag with set parameters on reminder, and flag content and timing.
(task would be great too, but that does not work before sending.

is there a way to handle email separation (to and cc) and distribution with flag / no flag to these separate recipients?

thanks
justice
 
If you are setting a flag before sending, it will go to all recipients. To send a flagged message only to the To line would require you to send two messages - one to CC , one to To.
Hi Diane,

thanks for the input - i could not figure out how to implement your suggestion

I have realized however, that i can solve this in a different way.
i can have limited number of guys as recipients (they should get the flag anyway) and hardcode in this macro a forward to others

so i add this after the above with section:

With objMsg
Set myForward = objMsg.Forward
myForward.Recipients.Add "alias@domain.com; alias2@domain.com"
myForward.Send
End With

there is only one problem with this: forward also forwards to the sender and that is not needed.
i was trying to use myForward.Recipients.Remove but could not figure a way to be able to run that.

is there a way to leave out the sender from this forward?

Thanks
JF
 
Remove is not the way to do it.

Try myForward.to "alias@domain.com; alias2@domain.com" - this should replace the original sender

if that doesn't work (adding two or more names using to sometimes fails), use
myForward.to "alias@domain.com;
myForward.Recipients.Add "alias2@domain.com"
Hello Diane,

many thanks for helping me!

i have changed the code to myForward.to but then it stops with "object does not support this method" (myforward.to "email")
this is the current code - which should run on a newly created message:

Public Sub SetCustomFlag()

Dim objMsg As Object

Set objMsg = GetCurrentItem()

With objMsg

.TaskDueDate = Now + 2
.FlagRequest = "REVIEW THIS ITEM " & objMsg.Subject
.FlagDueBy = Now+2
.ReminderSet = True
.ReminderTime = Now + 1
.Save

End With

'this part should forward the newly created message (all of its content) to the email address included. if this could be a local group, better

With objMsg
Set myForward = objMsg.Forward
myForward.To "alias@domain.com"
myForward.Send
End With

Set objMsg = Nothing
End Sub

many thanks yet again
justice
 
Hello Diane,

many thanks for helping me!

i have changed the code to myForward.to but then it stops with "object does not support this method" (myforward.to "email")
this is the current code - which should run on a newly created message:

Public Sub SetCustomFlag()

Dim objMsg As Object

Set objMsg = GetCurrentItem()

With objMsg

.TaskDueDate = Now + 2
.FlagRequest = "REVIEW THIS ITEM " & objMsg.Subject
.FlagDueBy = Now+2
.ReminderSet = True
.ReminderTime = Now + 1
.Save

End With

'this part should forward the newly created message (all of its content) to the email address included. if this could be a local group, better

With objMsg
Set myForward = objMsg.Forward
myForward.To "alias@domain.com"
myForward.Send
End With

Set objMsg = Nothing
End Sub

many thanks yet again
justice
Remove is not the way to do it.

Try myForward.to "alias@domain.com; alias2@domain.com" - this should replace the original sender

if that doesn't work (adding two or more names using to sometimes fails), use
myForward.to "alias@domain.com;
myForward.Recipients.Add "alias2@domain.com"
Hello and happy new year!
I am just taking this up again, do you have by chance any suggestion how to move forward with this?
thanks a ton
justice
 
I'll take a look at it - I took a few weeks off at the end of December and just getting back to work. :)
 
I'll take a look at it - I took a few weeks off at the end of December and just getting back to work. :)
I think the year end festive season is for fun, happy to hear that you've had some time off! :)

thinking about the problem - would it be better (easier) to create a new email with the contents of the flagged one, and send it to either hard coded recipients or better to local outlook address group?

thanks
justice
 
This is working for me -
Code:
Public Sub SetCustomFlag()

Dim objMsg As Object
Dim objRecip As Recipient
 
Set objMsg = GetCurrentItem()

With objMsg

.TaskDueDate = Now + 2
.FlagRequest = "REVIEW THIS ITEM " & objMsg.Subject
.FlagDueBy = Now + 2
.ReminderSet = True
.ReminderTime = Now + 1
.Save

End With

'this part should forward the newly created message (all of its content) to the email address included. if this could be a local group, better

With objMsg
Set myForward = objMsg.Forward
   
Set objRecip = myForward.Recipients.Add("alias@domain.com")
    objRecip.Type = olTo
    myForward.Send
End With

Set objMsg = Nothing
End Sub
 
This is working for me -
Code:
Public Sub SetCustomFlag()

Dim objMsg As Object
Dim objRecip As Recipient
 
Set objMsg = GetCurrentItem()

With objMsg

.TaskDueDate = Now + 2
.FlagRequest = "REVIEW THIS ITEM " & objMsg.Subject
.FlagDueBy = Now + 2
.ReminderSet = True
.ReminderTime = Now + 1
.Save

End With

'this part should forward the newly created message (all of its content) to the email address included. if this could be a local group, better

With objMsg
Set myForward = objMsg.Forward
  
Set objRecip = myForward.Recipients.Add("alias@domain.com")
    objRecip.Type = olTo
    myForward.Send
End With

Set objMsg = Nothing
End Sub

Hello Diane,

thanks for looking into this - really appreciate it!

This one certainly sends out a forward as well, which is a blitz for sure - but i encounter some problems:

- i prep a full mail, then press the button to invoke the above code/macro
- the macro sends a mail without the mail body, with the attachment, to both the original email recipient, and the coded one, w/o the flag and reminder
- then when pressing send on the original email, normal mail gets to the intended recipient with flag and body and attachment.

what i need to change is:
- mail recipient gets 2 mails - 1 from macro and 1 from normal send - but should get only one - the normal one after send (flagged etc)
- the macro recipient should receive a full mail - body and attachment (original mail recipient should not get this)

what should i change?

many thanks yet again
justice
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
J How to set a flag to follow up using VBA for outlook 2003 Using Outlook 10
L Help: set flag for sent mail to check if received an answer Outlook VBA and Custom Forms 2
S set a flag task date as the next weekday Outlook VBA and Custom Forms 4
J Set calendar default to 'none' (policy) Exchange Server Administration 3
U When opening shared Calendar "The set of folders cannot be opened" Using Outlook 0
D VBA - unable to set rule condition 'on this computer only' Outlook VBA and Custom Forms 5
Witzker Set Cursor & Focus from any field to the body of a user Contact form in OL 2019 Outlook VBA and Custom Forms 1
FryW Need help modifying a VBA script for in coming emails to auto set custom reminder time Outlook VBA and Custom Forms 0
O Cannot expand the folder. The set of folders cannot be opened. You do not have permission to log on. Using Outlook 1
e_a_g_l_e_p_i Outlook 2010 How to set default email address for website links Using Outlook 3
A Run-time error '430' on certain emails when trying to set "Outlook.mailitem" as "ActiveExplorer.Selection.Item" Outlook VBA and Custom Forms 2
e_a_g_l_e_p_i Is it possible it set the fonts used to read incoming mail Using Outlook 25
bmtjedi Set objApp = Application Not Working in O365-32bit Using Outlook 1
F how do i set a reminder in onenote 2010 Using Outlook 8
glnz How set up new IMAP on Outlook-Office 365 and merge in pst from Outlook 2003 for same two email accounts? Using Outlook 5
ChrisK2 Send email to advertise@slipstick.com fails: "The group advertising isn't set up to receive messages from..." Using Outlook 3
S How to set up button in ribbon for individual Quick Steps Using Outlook 1
J Set Timer/Countdown on Emails? Outlook VBA and Custom Forms 3
N How to set automatically the default or user defined Quickstyle Templates by Answer in Outlook Using Outlook 1
Victor_50 Set all subfolders to not autoarchive Outlook VBA and Custom Forms 11
Z Script to set account? Using Outlook 0
4 Macro to set the category of Deleted Item? Outlook VBA and Custom Forms 2
J What is the best EntryID format to set on MS Access table Outlook VBA and Custom Forms 3
e_a_g_l_e_p_i Can you set reminder to specific times? Using Outlook 7
CWM030 I do not see a way to set the personal archive folder Exchange Server Administration 2
Witzker Macro to set contact reminder to next day 9:00 Outlook VBA and Custom Forms 45
O Set columns for all (sub)folders Using Outlook 8
S Appointment-Cannot set Categories because ConversationID is not set Outlook VBA and Custom Forms 1
Fozzie Bear Correct Method to set up Outlook.com accounts as Exchange Using Outlook.com accounts in Outlook 7
e_a_g_l_e_p_i How to set fonts for emails in all folders in Outlook Using Outlook 1
F Set (flagged) reminder for next business day Using Outlook 4
L how to set downloaded cached emails Using Outlook 5
J Object Variable or With Block Not Set Error in Outlook 2016 and not Outlook 2013 Outlook VBA and Custom Forms 3
C Set reminder / appointment by right clicking email Using Outlook 1
Diane Poremsky Set Another Data File as Default When Using an Exchange Account Using Outlook 0
R Macro to copy email to excel - Runtime Error 91 Object Variable Not Set Outlook VBA and Custom Forms 11
L set task reminder date to same as start date (without affecting due date) Using Outlook 0
S how to set user properties to a newly created appointment Outlook VBA and Custom Forms 12
C Outlook VBA to set current account Outlook VBA and Custom Forms 1
Diane Poremsky Add Attachments and Set Email Fields During a Mail Merge Using Outlook 0
O How to set subject line in replies using VBA Outlook VBA and Custom Forms 1
A Custom form not showing when recurrence is set for a meeting Using Outlook 0
M Exchange 2013 On premise set MessageRateLimit for User has no effect. Exchange Server Administration 0
A Block user to send emails to specific set of email ids Using Outlook 1
D Outlook 2007 e-mail header- How to set font & font size in received message headers ? Using Outlook 2
Diane Poremsky Exchange account set-up missing in Outlook 2016 Using Outlook 0
M To set the storage folder for an outgoing Outlook message Outlook VBA and Custom Forms 8
E Meeting reminders are set for the recipient Exchange Server Administration 9
M Help! Can't set up IMAP for gmail Using Outlook 2
P Last Change attribute set after viewing a public folder contact Exchange Server Administration 0

Similar threads

Back
Top