none
Un-replied Emails RRS feed

  • Question

  • Hi Team,

    Below mentioned code is working Fine . However, I am trying to modify this code if Sender (From Mailbox Name) <> Recipient Mailbox Name then this code should work.  For Example : If I am sending any email from AAA shared mailed box and copying AAA shared mail box while sending email. Then that email should  not be moved into un-replied folder.

    Would really appreciate your inputs and modification in the current query.

    Option Explicit

    Public Sub CreateSearchFolder_AllNotRepliedEmails()
          Dim objstrScope As String
          Dim objstrRepliedProperty As String
          Dim objstrFilter As String
          Dim objSearch As Outlook.Search
          Dim objFolder As Outlook.MAPIFolder
          Dim objRecip As Outlook.Recipient

    Set objRecip = Application.Session.CreateRecipient("Mail box Name")
    Set objFolder = Application.Session.GetSharedDefaultFolder(objRecip, olFolderInbox)
     
    objstrScope = "'" & objFolder.FolderPath & "'"


         'Search filter       objstrRepliedProperty = "http://schemas.microsoft.com/mapi/proptag/0x10810003"
          objstrFilter = Chr(34) & objstrRepliedProperty & Chr(34) & " IS NULL " & " OR (" & _
                   Chr(34) & objstrRepliedProperty & Chr(34) & " <> 102" & "AND" & Chr(34) & objstrRepliedProperty & Chr(34) & " <> 103" & _
                   " ) "
          Set objSearch = Outlook.Application.AdvancedSearch(Scope:=objstrScope, Filter:=objstrFilter, SearchSubFolders:=True, Tag:="SearchFolder")

         'Save the search folder
          objSearch.Save ("Not Replied Emails")
          MsgBox "Search folder is created successfully!", vbInformation + vbOKOnly, "Search Folder"
      End Sub

    Thanks

    Ankit

    Monday, July 2, 2018 11:22 AM

Answers

  • Hello Ankit Singh Jadon,

    >>is there any way we can put a filter on date

    It seems a new requirement. We support one issue one one thread. If your original issue has been resolved, I would suggest you mark the helpful reply to close the thread.

    For adding filter on date, please post a new thread and detail your issue on it.

    Thanks for understanding,

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 17, 2018 7:32 AM

All replies

  • Hi Team,

    Below mentioned code is fine now. However, I am trying to modify this code if Sender (From Mailbox Name) <> Recipient Mailbox Name then this code should work. Also, When we run this code there should be Date Range filter from which date to which date you need to check if email has been not replied.

    Would really appreciate your inputs and modification in the current query.

    Option Explicit

    Public Sub CreateSearchFolder_AllNotRepliedEmails()
          Dim objstrScope As String
          Dim objstrRepliedProperty As String
          Dim objstrFilter As String
          Dim objSearch As Outlook.Search
          Dim objFolder As Outlook.MAPIFolder
          Dim objRecip As Outlook.Recipient

         

    Set objRecip = Application.Session.CreateRecipient("Mail box Name")
    Set objFolder = Application.Session.GetSharedDefaultFolder(objRecip, olFolderInbox)
    'objstrScope = "'" & objFolder.FlderPath & "'"
    objstrScope = "'" & objFolder.FolderPath & "'"


         'Search filter       objstrRepliedProperty = "http://schemas.microsoft.com/mapi/proptag/0x10810003"
          objstrFilter = Chr(34) & objstrRepliedProperty & Chr(34) & " IS NULL " & " OR (" & _
                   Chr(34) & objstrRepliedProperty & Chr(34) & " <> 102" & "AND" & Chr(34) & objstrRepliedProperty & Chr(34) & " <> 103" & _
                   " ) "
          Set objSearch = Outlook.Application.AdvancedSearch(Scope:=objstrScope, Filter:=objstrFilter, SearchSubFolders:=True, Tag:="SearchFolder")

         'Save the search folder
          objSearch.Save ("Not Replied Emails")
          MsgBox "Search folder is created successfully!", vbInformation + vbOKOnly, "Search Folder"
      End Sub

    Thanks

    Ankit

    Thursday, June 28, 2018 4:24 PM
  • Hello Ankit,

    I am trying to modify this code if Sender (From Mailbox Name) <> Recipient Mailbox Name then this code should work

    You may compare SenderEmailAddress with CurrentUser.Address property

    there should be Date Range filter from which date to which date you need to check if email has been not replied.

    Looks like you are interested in the PR_LAST_VERB_EXECUTION_TIME property value which returns contains the time when the last verb was executed. The DASL name is "http://schemas.microsoft.com/mapi/proptag/0x10820040".


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Thursday, June 28, 2018 7:25 PM
  • Hi Eugene,

    I did the same. However, it was not working for me. If I have a mailbox name for example : ABC. If email is coming from ABC and ABC also copied on the same email then that email should not be moved in the unreplied email folder.

    Can you please help me with that to modify the same code, which I have provided above.

    you help would be highly appreciated.

    Thanks

    Ankit

    Thursday, June 28, 2018 7:46 PM
  • Ankit,

    Looks like you need to check the Recipients collection for BCC addresses and compare them with the CurrentUser.Address property value.


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Friday, June 29, 2018 10:24 AM
  • Hello Ankit, 

    You need to compare the SenderEmailAddress property value of the incoming email with the CurrentUser.Address property value. The NameSpace.CurrentUser property returns the display name of the currently logged-on user as a Recipient object. The Address property of the Recipient class returns a string representing the e-mail address of the Recipient .


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Monday, July 2, 2018 2:26 PM
  • I tried to modify my current code as per your guidance. However, I am unable to modify it. Can you please modify it please ?
    Tuesday, July 3, 2018 7:39 AM
  • Hello Ankit Singh Jadon,

    You could try some thing like.

    objstrFilter = "(" & Chr(34) & objstrRepliedProperty & Chr(34) & " IS NULL " & " OR (" & _
                   Chr(34) & objstrRepliedProperty & Chr(34) & " <> 102" & " AND " & Chr(34) & objstrRepliedProperty & Chr(34) & " <> 103" & _
                   " )) AND ( NOT urn:schemas:mailheader:sender like '%" & objRecip & "%')"

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 5, 2018 9:10 AM
  • Hi Terry,

    Thank you so much for sharing this logic, is there any way we can put a filter on date. whenever we run this macro , it always ask From date - To Date.

    Friday, July 13, 2018 9:14 PM
  • Hello Ankit Singh Jadon,

    >>is there any way we can put a filter on date

    It seems a new requirement. We support one issue one one thread. If your original issue has been resolved, I would suggest you mark the helpful reply to close the thread.

    For adding filter on date, please post a new thread and detail your issue on it.

    Thanks for understanding,

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 17, 2018 7:32 AM