Outlook script for auto reply

Posted on 2009-02-17
Last Modified: 2012-05-06
I am in need of scripting an auto reply for outlook 2003.
I need this to key on part of the subject line and also the domain of the sending email address.
I then want my reply to have the original subject line with some additional text which I would define.
I would also define the body of the email to be sent.

To: Original sender
From: me
Subject: Original Subject plus what I have defined in the script.

Body of the email which I have defined in the script.

I appricate any help offered.
Question by:Stevrino
    LVL 76

    Expert Comment

    by:David Lee
    Hi, Stevrino.

    The two conditions can be handled by a rule.  I can post a script that'll do the rest.  There is an issue you need to be aware of though.  Sending a message via script is going to trigger Outlook's internal security.  The result will be a dialog-box popping up warnign you that an application is accessing your mailbox and asking for your permission to allow it to proceed.  That pretty much kills the process from being automatic.  There is no way to turn Outlook security off, but there are workarounds.  

    1.  Write the code as an add-in.  Add-ins have different security constraints from macros.  Unfortunately, they are also more difficult to write.

    2.  Sign the code with a digital signature.  A digital certificate is preferable, but you can "self-sign" code.  Here's a link to Microsoft instructions on how to do this:

    3.  Use Click-Yes.  This is a free third-party utility that sits in your system tray and watches for the security warning dialog-box.  When one pops up it clicks the Yes button for you.  In my opinion it's dangerous though.  Here's a link to it:

    4.  Outlook Redemption.  This too is a third-party utility that allows you to circumvent Outlook security.  It isn't risk free, but I believe it's safer.  It's not free though and is meant more for developers than a casual user.  Here's a link to it:

    Author Comment

    Thanks BlueDevilFan.
    I have a rule running already. The issue is it will only send 1 reply back to an address. I need it to send back to the same address if more than 1 email is sent, That is why I was thinking a script would be better. I do use Click-Yes now. I would also be interested in the "self-sign" you mentioned as well. I will look at it.
    So you are saying use rules for the conditions and a script for the rest? Tell me more.
    LVL 76

    Accepted Solution

    By having the rule fire a script, via the "run a script" action, the script will send a response every time a message meeting the rule condtions arrives.  Of course this is a client-side rule, so it will only work when Outlook is running.  You can edit the subject and body as you see fit.
    Sub Respond2Msg(Item As Outlook.MailItem)
        Dim olkMsg As Outlook.MailItem
        Set olkMsg = Item.Reply
        With olkMsg
            .Subject = Item.Subject & " My additional text goes here"
            .Body = "My body text"
        End With
        Set olkMsg = Nothing
    End Sub

    Open in new window


    Author Closing Comment

    Thanks BlueDevilFan, works like a charm.
    LVL 76

    Expert Comment

    by:David Lee
    You're welcome.  Glad I could help.

    Author Comment


    If I want more than 1 body line how can I do that with particular breaks.
    I see that HTML code will not work.
    I can get more than 1 line but it is just 1 big long one that splits over the required lines.
    LVL 76

    Expert Comment

    by:David Lee
    You can use HTML, we just need to change this line

        .Body = "My body text"


        .HTMLBody = "My body text<br>goes here"


    Author Comment

    Thanks again.
    I did find that in the help section after I asked you the question. I appreciate all your help.

    Expert Comment

    Is there a way to include the original mail in the, so if someone emails me, I can reply with a message including their mail inside it?



    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    My experience with Windows 10 over a one year period and suggestions for smooth operation
    Set OWA language and time zone in Exchange for individuals, all users or per database.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now