Results 1 to 28 of 28

Thread: Outlook: Check if a recipient has an automatic reply with a specific text

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    9

    Outlook: Check if a recipient has an automatic reply with a specific text

    Hi Fellas,

    I have a Excel list with emails in a specific row. I'd like to test them if they have a specific text in their automatic respond messages. If yes, I have to change status in the Excel file to 'Y'.

    I already tried it code it with python but I don't get access to the outlook MAPI. But I have no clue how to code it with VB.

    Does someone know how code should look like? I have found some code snippets here in the forum, but they didn't worked out.

  2. #2

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    9

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    Code:
    Sub CheckAutoReply()
    
    Dim OL As Outlook.Application
    Dim EM As Outlook.MailItem
    Dim R As Outlook.Recipient
    
    Set OL = New Outlook.Application
    Set EM = CreateItem(olMailItem)
    Creating a dummy mail? But how to extract the excel list names and check the response message?

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    I have a Excel list with emails in a specific row. I'd like to test them if they have a specific text in their automatic respond messages. If yes, I have to change status in the Excel file to 'Y'.
    is the list of emails the email addresses?

    this is a basic sample to look at all emails within some folder in inbox and it's subfolders
    Code:
    set ol = createobject("outlook.application")
    Set ns = ol.GetNamespace("mapi")
    Set ofolder = ns.GetDefaultFolder(olFolderInbox).Folders("test")
    For Each f In ofolder.Folders
        For Each msg In f.Items
            if msg.sendername = cells(3,1) then Debug.Print msg.subject, f.Name
        Next
    Next
    i just list out the subject lines and folder here, but you can do whatever you want, change the range address for cell to match email addess
    you can use the restrict method of the messages collection to save looping through all messages in a folder
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    9

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    The list of emails is listed in a excel file not a inbox.

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    The list of emails is listed in a excel file not a inbox.
    so where are the auto responds

    if every thing is in excel, why do you want to automate outlook
    the description of your problem leaves a lot to the imagination

    what exactly is in excel? and how is it arranged (what columns)?
    what do you want to find from where?
    where is the excel status to change to Y?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    9

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    Quote Originally Posted by westconn1 View Post
    so where are the auto responds

    if every thing is in excel, why do you want to automate outlook
    the description of your problem leaves a lot to the imagination

    what exactly is in excel? and how is it arranged (what columns)?
    what do you want to find from where?
    where is the excel status to change to Y?
    The Auto respond message is from outlook itself, when you type in the email adresse in the "to" field, a message appears above the field.

    For my automation it's not about Outlook. I want just to check if there is a specific auto respond message available for each email.

    A2 - Yes/Leave Empty if not
    B2:A700 - email adresses

    I have to set a yes in the A column, when there is a respond message part with the text e.g "not in house ..." I have to look for some words.

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    For my automation it's not about Outlook
    the excel part is pretty easy, automating outlook refers to using code to operate outlook form some other application

    The Auto respond message is from outlook itself, when you type in the email adresse in the "to" field, a message appears above the field.
    i will have to look into this further as i do not think my version of outlook has this provision
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    Quote Originally Posted by beatmaker View Post
    The Auto respond message is from outlook itself, when you type in the email adresse in the "to" field, a message appears above the field.

    For my automation it's not about Outlook. I want just to check if there is a specific auto respond message available for each email.

    A2 - Yes/Leave Empty if not
    B2:A700 - email adresses

    I have to set a yes in the A column, when there is a respond message part with the text e.g "not in house ..." I have to look for some words.
    If you are not automating Outlook at any point then where are you reading the emails from to check for an OOF reply?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    doesn't an out of office auto response go to all emails received, based on criteria as set up?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    Quote Originally Posted by westconn1 View Post
    doesn't an out of office auto response go to all emails received, based on criteria as set up?
    Correct, so if the user has some rule it may not apply nor reply with the automated message. Plus, there are web mail interfaces which can also produce an out of office reply. It doesnt seem like there is a concrete footprint to detecting an out of office reply.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  11. #11
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    he really needs to clarify the question, and why some may not be set up to have an auto response
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  12. #12

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    9

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    Quote Originally Posted by westconn1 View Post
    he really needs to clarify the question, and why some may not be set up to have an auto response
    Because that's the only way to check if user is still working for us or not anymore.

  13. #13
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    Because that's the only way to check if user is still working for us or not anymore.
    lol!!
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  14. #14
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    Quote Originally Posted by beatmaker View Post
    Because that's the only way to check if user is still working for us or not anymore.
    The best sure fire way to know if a user is still employed with your company is to validate their windows login account against your companies Active Directory. If they dont have a windows logon and only company email then querying against the exchange server or webhost for a valid account would be best vs sending emails to see if its out of office etc
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  15. #15

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    9

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    Not possible because I don't have server access That's the only way to check via outlook. That's I thought to automate reading the responses.

  16. #16
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    so if the user is no longer working there, you get some automated response to your inbox, for your email query to him/her?

    do you want to send an email to all email addresses on your list, to see if you get a vaild (human) response or the automated one?
    if this is what you want to do it is relatively simple, though any response to an email may take some time to come and may not come in the order of the sent queries
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  17. #17

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    9

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    Quote Originally Posted by westconn1 View Post
    so if the user is no longer working there, you get some automated response to your inbox, for your email query to him/her?

    do you want to send an email to all email addresses on your list, to see if you get a vaild (human) response or the automated one?
    if this is what you want to do it is relatively simple, though any response to an email may take some time to come and may not come in the order of the sent queries
    No, I do not want to send emails neither do I get mails. At this moment I copy about 50 emails from my list and paste them in to the "send to" field. Outlook fetch the automatic reply and it pops out (see image from internet as example). And when there is a specific text e.g. "I'm not working here", I'm editing the list and add a "yes" next to this email adress.

    Name:  gg675927.Fig_1_Creating_an_online_meeting_directly_within_Outlook_using_Office_365(en-us,MSDN.10.jpg
Views: 1730
Size:  24.5 KB
    Last edited by beatmaker; Jun 27th, 2017 at 03:34 AM.

  18. #18
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    now i understand better, try like

    Code:
    Set ol = CreateObject("outlook.application")
    Dim r As Recipient, n As NameSpace, t As String
    t = "I'm not working here"
    Set n = ol.GetNamespace("mapi")
    For rw = 2 To 700
        Set r = n.CreateRecipient(cells(rw, 2))
        If InStr(r.AutoResponse, t) > 0 Then cells(rw, 1) = "YES"
    Next
    ol.quit
    i can not test this, as no one in my recipients list would have any autoresponse (i am not on an exchange server) set up

    edit: to check if the recipient is a valid email address in your address book you would need to check that each recipient has an addressentry.address
    Last edited by westconn1; Jun 27th, 2017 at 04:53 AM.
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  19. #19

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    9

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    In excel or outlook?

    I've tried in outlook but it's closing my outlook app (ol.Quit) and blocked authorization of excel file.

    For your information: The auto replay is different each time because autoreplay contains their names at the beginning ... "I'm out of work Name Surename. Visit us at website."

  20. #20
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    For your information: The auto replay is different each time because autoreplay contains their names at the beginning ... "I'm out of work Name Surename. Visit us at website."
    i used instr to do a partial match, but obviously you will need to have some common text

    In excel or outlook?
    i assumed you would be working within excel and automated outlook, but it could be easily modified to work from outlook and automate excel

    if outlook is already open remove the ol.quit, it does not matter anyway, if outlook is left open after the code has completed, i was just tidying up
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  21. #21

    Thread Starter
    New Member
    Join Date
    Jun 2017
    Posts
    9

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    Quote Originally Posted by westconn1 View Post
    i used instr to do a partial match, but obviously you will need to have some common text
    With python you can match parts of a text. Is it not possible to regex in vb? e.g.:

    Code:
    Dim foo = "I'm out of work Name Surename. Visit us at website."
    
    Dim match = Regex.Match(foo, "X", RegexOptions.IgnoreCase)
    I've tested the code but nothing is happen.
    Code:
    Public Const ressourcePlanFile_ As String = "C:\.xls"
    Public Const worksheet_ As String = "worksheet"
    
    Sub CheckData()
    
     Dim xlApp As Excel.Application
     Dim sourceWB As Excel.Workbook
     Dim sourceWS As Excel.Worksheet
     
     Set xlApp = CreateObject("Excel.Application")
     
      With xlApp
     .Visible = False
     .EnableEvents = False
     End With
    
     Set sourceWB = Workbooks.Open(ressourcePlanFile_, , False, , , , , , , True)
     Set sourceWH = sourceWB.Worksheets(worksheet_)
    
    Set ol = CreateObject("outlook.application")
    Dim r As Recipient, n As NameSpace, t As String
    t = "I'm out of work"
    Set n = ol.GetNamespace("mapi")
    For rw = 2 To 100
        Set r = n.CreateRecipient(Cells(rw, 13))
        If InStr(r.AutoResponse, t) > 0 Then Cells(rw, 3) = "Yes"
    Next
    
    End Sub

  22. #22
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,906

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    Nothing happens...

    You are writing the "Yes" in Cells(rw, 3)
    What is Cells??
    It's not part of your xlApp, sourceWB or sourceWS

  23. #23
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    Quote Originally Posted by beatmaker View Post
    With python you can match parts of a text. Is it not possible to regex in vb? e.g.:

    Code:
    Dim foo = "I'm out of work Name Surename. Visit us at website."
    
    Dim match = Regex.Match(foo, "X", RegexOptions.IgnoreCase)
    I've tested the code but nothing is happen.
    Code:
    Public Const ressourcePlanFile_ As String = "C:\.xls"
    Public Const worksheet_ As String = "worksheet"
    
    Sub CheckData()
    
     Dim xlApp As Excel.Application
     Dim sourceWB As Excel.Workbook
     Dim sourceWS As Excel.Worksheet
     
     Set xlApp = CreateObject("Excel.Application")
     
      With xlApp
     .Visible = False
     .EnableEvents = False
     End With
    
     Set sourceWB = Workbooks.Open(ressourcePlanFile_, , False, , , , , , , True)
     Set sourceWH = sourceWB.Worksheets(worksheet_)
    
    Set ol = CreateObject("outlook.application")
    Dim r As Recipient, n As NameSpace, t As String
    t = "I'm out of work"
    Set n = ol.GetNamespace("mapi")
    For rw = 2 To 100
        Set r = n.CreateRecipient(Cells(rw, 13))
        If InStr(r.AutoResponse, t) > 0 Then Cells(rw, 3) = "Yes"
    Next
    
    End Sub
    Yes you can use RegEx in VBA. Add a project reference to "Microsoft VBScript Regular Expressions 5.5" and then you will have it.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  24. #24
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    Quote Originally Posted by Arnoutdv View Post
    Nothing happens...

    You are writing the "Yes" in Cells(rw, 3)
    What is Cells??
    It's not part of your xlApp, sourceWB or sourceWS
    Cells is the WorkSheet cells object. Should be referencing it derrived off of an object variable
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  25. #25
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,906

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    I know it's the worksheets Cells object if you are programming in Excel VBA, but if this is the case then why have a reference to Excel.Application.
    Or TS is using Cells without the complete reference like sourceWS.Cells()

  26. #26
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,710

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    Quote Originally Posted by Arnoutdv View Post
    I know it's the worksheets Cells object if you are programming in Excel VBA, but if this is the case then why have a reference to Excel.Application.
    Or TS is using Cells without the complete reference like sourceWS.Cells()
    I'd say the excel object variables are used for referencing the other aka source workbook from within the active workbook and the OP is not doing the same by using the active objects. Its always good practice to create and reference object variables instead of the "active" sheet or ranges etc. While the code is running if the user clicks on a sheet it could change the active sheet thus throwing off which sheet data is being written etc
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  27. #27
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,906

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    And you risk Excel not close when terminating all objects because of these implicit references.

    Id say the excel object variables are used for referencing the other aka source workbook from within the active workbook and the OP is not doing the same by using the active objects
    Automating an instance of Excel from within Excel itself? Sounds ... odd.

  28. #28
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Outlook: Check if a recipient has an automatic reply with a specific text

    if you are more familiar with python you could adapt the vba to python easily enough, just createobjects for both excel and outlook as you are doing

    if you are working in vba, within 1 of those applications, you co not need to createobject for the application you are working in, as its object model is already available

    i assumed you were working within excel, so the code i posted would read and write to the activesheet, not that that is good practice, much better to use full qualified ranges, like
    Code:
    Set r = n.CreateRecipient(sourceWH.Cells(rw, 13).value)
    as mentioned above by rob, regex will work fine in vba, i really left it up to you how you matched your strings, just providing a basic example, based on information supplied

    if you have an email address that you know has an autoresponse, you can test that the code returns the correct result
    within outlook vba
    Code:
    Dim r As Recipient, n As NameSpace
    Set n = application.GetNamespace("mapi")
        mytestemail = "someemailaddress"
        Set r = n.CreateRecipient(mytestemail)
        msgbox r.AutoResponse
    then just make sure your string matching works correctly
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width