How to delete mails which are 3 months and or older in Outlook

My rpa Inbox in almost full with 70000 mails I need to delete the mails which are 3 months and older from it. How do I achieve this ?

1 Like

Hello @Ishan_Shelke ,

You could try this sequence of activities:

More info about activities you can find here:

Hope it helps!
Best regards,
Marius

3 Likes

Hi @Ishan_Shelke,

  1. Assign activity: currentDate = Now

  2. Assign activity: cutoffDate = currentDate.AddMonths(-3)

  3. For Each activity:
    TypeArgument: System.Net.Mail.MailMessage
    Values: List of emails in inbox

    Body of For Each:
    Assign activity:
    emailDateString = item.Headers(“Date”)

    Assign activity:
    emailDate = DateTime.ParseExact(emailDateString, “ddd, dd MMM yyyy HH:mm:ss zzz”, CultureInfo.InvariantCulture)

    If activity:
    DateTime.Compare(emailDate, cutoffDate) < 0
    Then activity:
    item.Delete()

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.