Help With Outlook Macro For Replying To An Email

Necroscope

Board Regular
Joined
Jul 7, 2004
Messages
72
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
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
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.
 
Upvote 0
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! :banghead:
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,707
Members
452,939
Latest member
WCrawford

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top