Consulting

Results 1 to 5 of 5

Thread: Outlook set expiry date & redirect the email

  1. #1

    Outlook set expiry date & redirect the email

    Hi All,

    Trying to establish whether is a possible set expiry date(30 days) for incoming emails then redirect that email to different recipients/groups.

    I want to run that as outlook rule, triggered by certain keywords and then start a script. I have seen outlook scripts for setting expiry date(see below) but wondering whether someone could help me?

    Thank you


    Public WithEvents olItems As Items

    Private Sub Application_Startup()
    Set olItems = Application.Session.GetDefaultFolder(olFolderInbox).Items
    End Sub

    Private Sub olItems_ItemAdd(ByVal Item As Object)
    Dim strMsg As String
    Dim nRes As Integer

    If Item.ExpiryTime = #1/1/4501# Then
    Item.ExpiryTime = DateAdd("m", 1, Item.ReceivedTime)
    End If

    Item.Save
    End Sub

  2. #2
    Are you sure that it's the expiry date parameter you want to change? If so then a script attached to a rule should do the job as the messages arrive e.g.

    Sub SetLimitAndSendOnMessage(olItem As MailItem)
    Dim olOutMail As Outlook.MailItem
        Set olOutMail = olItem.Forward
        With olOutMail
            .To = "someone@somewhere.com"
            .ExpiryTime = Date + 30
            .Display
            '.Send 'Enable after testing
        End With
    lbl_Exit:
        Set olOutMail = Nothing
        Exit Sub
    End Sub
    You can test the code by selecting a message in your InBox and running the following

    Sub testMacro()
    Dim olMsg As MailItem
        On Error Resume Next
        Set olMsg = ActiveExplorer.Selection.Item(1)
        SetLimitAndSendOnMessage olMsg
    lbl_Exit:
        Exit Sub
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    Yes I want to set expiry date for each incoming email and then forward that copy of that email(with expiry date).


    I have tested and forwarding is working and in destination mailbox copy of email is there with expiry date but not for email from source mailbox.

    Thank you

  4. #4
    As I understand it the expiry date is an option relating to the sending of a message and not to a message that has been received. The expiry date is therefore set for the message you are actually sending, which is the forwarded copy.
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  5. #5
    Okay, what I would like this to work is for all incoming emails set expiry date to 30 days then forward copy of that email.

    Is that possible?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •