We help IT Professionals succeed at work.

Word Merge - Manipulate Outlook Emails (Add a Reminde to follow-up)

635 Views
Last Modified: 2012-06-07
I am using the following code to add attachments, and make to changes created by Word Mail merge.

Everything seems to work pretty good but the flag and reminder updates:

               .FlagDueBy = CStr(DateAdd("d", 10, Int(Now()))) & " 08:00"
               .FlagIcon = olBlueFlagIcon
               .Categories = "0_Owners Representative, _0Priority Follow-up,  Agriculture Client"

What I want to do is add a flag for myself with a reminder to follow-up on the email in a predeterminded number of days.

I tried to find more information on the flag and reminder propertieas and how they work, but had no success

Any help would be appreciated.

Thanks

Roger
-----------------------------------------------------------------------

Sub a_OutlookOutboxAddAttachnmentsToEmails()
    Dim olkApp As Object
    Dim mai As Object
    Dim acct As Long
    Dim fldr As Object
    Dim OfflineChk As Boolean
    Dim UserSelectOfflineYN As Boolean
       
    Dim ctl As Office.CommandBarControl
       
       
        acct = getAccount
        If acct = 0 Then acct = 1
        Set olkApp = CreateObject("outlook.application")
       
    Set fldr = olkApp.Session.PickFolder

    If fldr Is Nothing Then Exit Sub
      For Each mai In fldr.Items
          If mai.Class = 43 Then
              With mai
                .Importance = 2
                .ReadReceiptRequested = True
                .OriginatorDeliveryReportRequested = True
                .Attachments.Add "r:\icm\ICM Owner's Representative Services.pdf"
                .Attachments.Add "r:\icm\ICM Services Brochure - Email Version.pdf"
                .SendUsingAccount = olkApp.Session.Accounts.Item(acct)
                .SentOnBehalfOfName = olkApp.Session.Accounts.Item(acct)
                '.CC = "nmonicalal@aol.com; btolland@tbdconsultants.com; cwallender@sgh.com"
                .BCC = "kelleyc@wrdarch.com"
                .FlagDueBy = CStr(DateAdd("d", 10, Int(Now()))) & " 08:00" ' today + 10 days @ 8:00 AM
                .FlagIcon = olBlueFlagIcon
                .Categories = "0_Owners Representative, _0Priority Follow-up,  Agriculture Client"
                '.Display
                .Save
                '.Send
            End With
        End If
     
    Next

End Sub

Function getAccount() As Long
Dim olkApp As Object
Dim i As Long
   
    Set olkApp = CreateObject("outlook.application")
    For i = 1 To olkApp.Session.Accounts.Count
        If (MsgBox("Use Account " & olkApp.Session.Accounts.Item(i).SmtpAddress, vbYesNo)) = vbYes Then 'olkApp.Session.accounts.item(i)
            getAccount = i
            Exit For
        End If
    Next

End Function
Comment
Watch Question

CERTIFIED EXPERT

Commented:
Object MailItem has properties ReminderTime and ReminderSet . More at http://msdn.microsoft.com/en-us/library/ff868512.aspx
CERTIFIED EXPERT

Commented:
Why are you converting the calculated date to a string?

 .FlagDueBy = CStr(DateAdd("d", 10, Int(Now()))) & " 08:00"


the FlagDueBy element is a Date type. Your expression returns a string that looks like a date and time value, but it's not quite right, as there is no AM/PM portion, so that may be the source of the problem,

Also, there's no need to use Int(Now()) to get the date portion of Now(), instead just use the Date() function.  (BTW it you really need the date part only of a Date data item you should use DateValue(SomeDateVariable) instead of Int(SomeDateValue).

This expression returns an actual date type with the value you need

DateAdd("d",10,Date()) + TimeValue("08:00")

which, today, would return the  value 4/9/2012 8:00:00 AM

so your code should read

.FlagDueBy = DateAdd("d",10,Date()) + TimeValue("08:00")

Lambert
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.