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
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