View Single Post
 
Old 10-02-2015, 11:02 AM
Son Son is offline Windows 8 Office 2013
Novice
 
Join Date: Oct 2015
Posts: 1
Son is on a distinguished road
Question If Statement for Outlook VBA: Time & User defined columns

Hello,

I am new to VBA and i am finding If/Then statements difficult. I have tried to create this, but i am not sure if this is the correct way.

I appreciate any help/suggestions to help me understand this a little better.

What i would like to do is create an If statement for a User Defined Field Column in Outlook. I have created a User defined field column called "Overdue".

I want to create an if then statement where, if an email is selected and has the value of "A" in UDF 2 and the flag status is not marked as complete; then there is a timer of 4 hours for this task to be completed- but the task timer should start as soon as the mail item reaches the mailbox.

If this is not overdue, then Column "Overdue"(UDF4) will stay as "No", if this is Overdue; >4 hours, this column will be set as the value "Yes"

Below is the code that i have been working on:


Code:
 For Each msg In myCollection
   If msg.FlagStatus = olFlagComplete Then
   End If

    If str2 = "A" + TaskDueDate = ReceivedTime > 4 Then 'check if received time is > than 4 hours

    ''''If Hour (?)()) < 4 Then (comment:alt line of code)
    msg.str4 = "Yes" 'if the received time for that message is more than 4 hours set Overdue column to say Yes
    Set objProperty = msg.UserProperties(udf(4))

    If TaskDueDate = ReceivedTime < 4 Then
    msg.str4 = "No"
        Set objProperty = msg.UserProperties(udf(4))

    If (objProperty Is Nothing) Then
       Set objProperty = msg.UserProperties.Add(udf(4), olKeywords)

 End If 
    objProperty.value = "No"`

     msg.Save
     Next
     End If
         End If
    End Sub
Reply With Quote