# Help With Outlook Macro For Replying To An Email



## Necroscope (Mar 4, 2011)

Hi guys.

I am trying to create a simple Macro in Outlook (2002) which will send a reply back to the original email recipient with specific text in the subject and body. (I know I could probably do this using Rules but I need to be able to manually choose who to send this reply to.)

I found some VBA and tailored it to suit but when I click on the menu button that I linked to this Macro, I get a prompt saying, "A program is trying to automatically send e-mail on your behalf..." and you need to click YES to send it. If you click NO, you get a debug error.

Is there something in the code (copied below) that I can add/amend to stop this prompt from appearing? (I thought this message only appeared if you use VBA from another program, not when entering VBA directly into Outlook.)

Also, when I click on the Macro button, it opens up the auto-reply in a new window so that I'm still left with the original email open. Is there a line of code I can enter that will close this email too? I would appreciate your help.

Sub EmailReply()
Dim Reply As Outlook.MailItem
Dim Original As Outlook.MailItem
Set Original = Application.ActiveExplorer.Selection(1)
Set Reply = Original.Reply
Reply.Attachments.Add Original
Reply.Subject = "Important Notice"
Reply.Body = "Body text to be entered here"
Reply.Display
Reply.Send
End Sub

Thanks.

Richard


----------



## Necroscope (Mar 5, 2011)

Anyone?


----------



## BrianB (Mar 5, 2011)

FWIW I had no problems with your code. (office 2010) No error messages etc.
I think you need to check your antivirus or other security settings.


----------



## Necroscope (Mar 7, 2011)

Hi BrianB.

Thanks for the info. I'm using this VBA in Outlook at work so maybe there's some security setting causing the problem? Oh well, I might just have to live with it!


----------



## Derek Brown (Mar 7, 2011)

You need to add a 'Self Certificate'.
It works for me in XP/Office 2007, Windows 7/Office 2007 and Windows Server 2008 R2/Office 2007. I have not yet tried it with Office 2010.

Follow the instructions at:
http://www.howto-outlook.com/howto/selfcert.htm


----------



## askquestion2013 (Mar 3, 2013)

This code word but I need a condition to first read the rule set then auto reply. Anyone can help?


----------

