none
Automatic reply on incoming messages in outlook 2010 (connected to Exchange Server 2010) using VBA RRS feed

  • Question

  • Dear Sir/Madam,

    I have used the rule to run as a script for below coding about autoreply in Outlook 2010 which connected to Exchange Server 2010. I have some issues as below, hopeful can give some advice:

    1. The coding can work in 1 PC but can't work in 1 PC, which setting should I check so that the coding can work in all PCs?

    2. If the sender send one email, I find the coding continue to reply more than 1 autoreply email and repeat many times, it stop until I stop to run rule. which coding should modify in order to autoreply 1 time only?

    3. If I want to autoreply with outlook template (include subject, content, signature and company logo), which  coding should modify to support this? 

    4. I would be grateful if someone can give another coding which can solve the above mentioned issues?

    Option Explicit

    Sub AutoReply(olItem As Outlook.MailItem)
    Dim olOutMail As Outlook.MailItem
        With olItem
            Set olOutMail = olItem.Reply
            With olOutMail
                .Body = "This is the reply text"
                .Send        
             End With
            Set olOutMail = Nothing
        End With
    End Sub

    Sub Test()
    Dim olMsg As MailItem
    On Error Resume Next
    Set olMsg = ActiveExplorer.Selection.Item(1)
    AutoReply olMsg
    End Sub

    Thank you very much for your help and attention.

    Best Regards,
    Stanley

    Wednesday, August 2, 2017 4:47 PM

Answers

  • Hi Stanley,

    ->The coding can work in 1 PC but can't work in other PC, which setting should I check so that the coding can work in all PCs?

    Please check macro security setting in Option->Trust Center->Trust Center Setting->Macro Settings.

    ->If the sender send one email, I find the coding continue to reply ...

    The macro should run after receiving a mail. What do you mean sending one mail?

    ->If I want to autoreply with outlook template (include subject, content, signature and company logo), which  coding should modify to support this?

    Please check below code.

    Sub AutoReply(olItem As Outlook.MailItem)

    Dim olOutMail As Outlook.MailItem

    Set olOutMail = Application.CreateItemFromTemplate("C:\Users\Administrator\Desktop\demo template.oft")

    olOutMail.To = olItem.Reply.To

    olOutMail.Send

    Set olOutMail = Nothing

    End Sub

    BTW, I suggest you post multiple threads for multiple issues so that you could provide more details for each issue. Thanks for understanding.

    Best Regards,

    Terry

    • Marked as answer by Stanleycha Thursday, August 10, 2017 4:20 PM
    Friday, August 4, 2017 10:06 AM

All replies

  • Hi Stanley,

    Thanks for posting in our forum.

    Then here we mainly focus on general questions about Outlook client. As your query is more related to developing issues involving Outlook, we'll move your thread to the following dedicated MSDN forum for Outlook:

    https://social.msdn.microsoft.com/Forums/en-US/home?forum=outlookdev

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.

    By the way, could you please provided more details about the rule you have used then our engineers and community members can help you better? You may share an screenshot via OneDrive and paste a link here.

    Best regards,
    Yuki Sun


    Please remember to mark the replies as answers if they helped.

    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Thursday, August 3, 2017 3:08 AM
  • Dear Yuki Sun,

    Thanks for your help. I used the rule in outlook 2010  (Apply this rule after the message arrives -> sent only to me-> and on this computer only -> run autoreply (i.e. script as below):

    Option Explicit

    Sub AutoReply(olItem As Outlook.MailItem)
    Dim olOutMail As Outlook.MailItem
        With olItem
            Set olOutMail = olItem.Reply
            With olOutMail
                .Body = "This is the reply text"
                .Send        
             End With
            Set olOutMail = Nothing
        End With
    End Sub

    Sub Test()
    Dim olMsg As MailItem
    On Error Resume Next
    Set olMsg = ActiveExplorer.Selection.Item(1)
    AutoReply olMsg
    End Sub

    1. The coding can work in 1 PC but can't work in other PC, which setting should I check so that the coding can work in all PCs?

    2. If the sender send one email, I find the coding continue to reply more than 1 autoreply email and repeat many times, it stop until I stop to run rule. which coding should modify in order to autoreply 1 time only?

    3. If I want to autoreply with outlook template (include subject, content, signature and company logo), which  coding should modify to support this? 

    4. I would be grateful if someone can give another coding which can solve the above mentioned issues?

    Thank you very much for your help and attention.

    Best Regards,
    Stanley

    Thursday, August 3, 2017 4:37 PM
  • Hi Stanley,

    ->The coding can work in 1 PC but can't work in other PC, which setting should I check so that the coding can work in all PCs?

    Please check macro security setting in Option->Trust Center->Trust Center Setting->Macro Settings.

    ->If the sender send one email, I find the coding continue to reply ...

    The macro should run after receiving a mail. What do you mean sending one mail?

    ->If I want to autoreply with outlook template (include subject, content, signature and company logo), which  coding should modify to support this?

    Please check below code.

    Sub AutoReply(olItem As Outlook.MailItem)

    Dim olOutMail As Outlook.MailItem

    Set olOutMail = Application.CreateItemFromTemplate("C:\Users\Administrator\Desktop\demo template.oft")

    olOutMail.To = olItem.Reply.To

    olOutMail.Send

    Set olOutMail = Nothing

    End Sub

    BTW, I suggest you post multiple threads for multiple issues so that you could provide more details for each issue. Thanks for understanding.

    Best Regards,

    Terry

    • Marked as answer by Stanleycha Thursday, August 10, 2017 4:20 PM
    Friday, August 4, 2017 10:06 AM
  • Dear Terry,

    Thanks for your help. My Outlook 2010 (connected to Exchange server 2010) can access my personal email and shared mailbox, how to I use rule and run as a script to apply autoreply for shared mailbox? Can I use the same autoreply rule used in personal mail to shared mailbox? Do I need full access permission for shared mailbox in order to create autoreply rule?

    Thanks for your help again.

    Regards,
    Stanley Chan

    Tuesday, August 8, 2017 4:52 PM
  • Hi Stanleycha,

    Has your original issue been resolved? If it has, I would suggest you mark the helpful reply as answer or provide your solution and mark as answer to close this thread. If not, please feel free to let us know your current issue. For your new issue, I suggest you post a new thread for help. Thanks for understanding.

    Best Regards,

    Terry

    Thursday, August 10, 2017 11:07 AM
  • Dear Terry,

    The original issue has been resolved. I have posted new issue to new thread.

    Best Regards.
    Stanley

    Thursday, August 10, 2017 4:30 PM