Linker IT Software
Google
Web www.oraxcel.com
menubar-top-links menubar-top-rechts
Home Help Search Login
Welcome, Guest. Please Login.
SQL*XL: Database to Excel bridge litLIB: Excel power functions pack ExcelLock: Locking and securing your valuable Excel spreadsheets encOffice: Protect your Excel file easy and safe encOffice: Protect your Excel file easy and safe
Pages: 1
Outlook: Send same reply to multiple emails. (Read 34322 times)
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 18
Outlook: Send same reply to multiple emails.
12.04.06 at 14:20:52
 
Send the same reply to multiple emails in MS Outlook
 
This is a scenario that I find myself in regularly. If you have multiple emails that you want to send the same reply to it is quite elaborous to open each email and send the reply.
 
For this scenario I have written a macro that works very well in Outlook 2000.  
 
How to use this macro:
Create a new email and type the message you want to send to everyone.  
Then select all the emails you want to reply to. You can hold the Shift key to select a block of emails or you can hold the Ctrl key to add individual emails to the selection.
When you have selected all the emails you want to reply to bring the email back to the front you just typed.
In that reply email window select Tools and macros.
Select the send_to_all macro a press ok.
While the macro is running do not press any keys and do not operate the mouse.
 
How to install this macro:
Open MS Outlook
Press Alt-F11 to start the Visual Basic Editor
Select Project1
Right click and select: insert, module
Locate the new module and enter the code below.
Press the save button before you close the Visual Basic Editor
 
Code:
Sub send_to_all()
    Dim o As MailItem
    Dim CurrentItem As MailItem
    Dim email As MailItem
    Dim lCount As Long
    Dim l As Long
    
    Set CurrentItem = ActiveWindow.CurrentItem
    Set o = ActiveInspector.CurrentItem.Copy
    
    Application.ActiveWindow
    lCount = ActiveExplorer.Selection.count
    For l = 1 To lCount
	  DoEvents
	  Set email = ActiveExplorer.Selection.Item(l)
	  o.To = email.SenderName
	  o.Display True
	  SendKeys "%S{ENTER}", True
	  Set o = ActiveInspector.CurrentItem.Copy
    Next l
 End Sub
 

Back to top
 
« Last Edit: 12.04.06 at 14:31:46 by Gerrit-Jan Linker »  

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 18
Re: Outlook: Send same reply to multiple emails.
Reply #1 - 23.10.07 at 21:42:09
 
Someone wrote to me by email:
 
I tried out your solution to "Send the same reply to multiple emails in MS Outlook".
 
I get an error:  
"Compile error: user-defined type not defined"
 
I am doing exactly as you have described.
 
Using:  
MS Outlook 2003 (word as e-mail editor; I created the macro in both Outlook and Word).
I Ctrl select the e-mails from the Sent Items folder
Back to top
 
 

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 18
Re: Outlook: Send same reply to multiple emails.
Reply #2 - 25.10.07 at 22:16:46
 
Aparently the error "Compile error: user-defined type not defined" happens on the first row of the procedure:
 
Dim o As MailItem
 
MailItem could not be found as a class. MailItem is part of the Outlook object itself so I am a little surprised it does not work. You did enter the code in Outlook didn't you?
 
When I prefix the MailItem class with Outlook it also works. Please try that.  
Enter this:
Dim o As Outlook.
 
When entering the . a dropdown list should appear with all the available Outlook classes. Select the MailItem class to code:
 
Dim o as Outlook.MailItem
Back to top
 
 

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
nill
YaBB Newbies
*


I Love SQL*XL

Posts: 0
Re: Outlook: Send same reply to multiple emails.
Reply #3 - 26.10.07 at 18:09:00
 
Hi,
 
Thank you much very for willing to help me Smiley
 
But it still does not work. Please note these two different problems/erros Sad
 
1)  
I used Outlook.MailItem (I did see the dropdown) in Outlook (pressed Alt+F11 in Outlook). Then I hit F5 to compile, but got this error:
Run-time error '438': Object doesn't support this proprety or method
 
2)
I use MS Word as e-mail editor, so Outlook uses Word to compose new messages. In the new e-mail window (the e-mail that I want to send to multiple recipients), when I run a macro, it runs from Word (it does not see the Outlook macro). So I added the same macro code to Word (Opened word and pressed Alt+F11). In this case when I hit F5, I get this error (even with Outlook.MailItem):
Compile error: User defined type not defined.
 
Please tell me how to rectify this issue. I will be very grateful.
 
Thanks and kind regards!
Back to top
 
« Last Edit: 26.10.07 at 18:10:21 by nill »  
Email   IP Logged
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 18
Re: Outlook: Send same reply to multiple emails.
Reply #4 - 26.10.07 at 20:29:31
 
Ah, well that explains why it doesn't compile. You entered the code in VBA in Word. Word doesn't have a MailItem class. You could make it compile by adding a reference to the Word project to Outlook. However this is not what you want to do.
 
Irrespective of the fact that you use Word to make a new email you need to put the code to send the email to multiple recipients in Outlook. Without looking at your new email, just press Alt-F11 to go to the visual basic editor in Outlook. Add the code there. Close visual basic and only now turn to your email. Compose your email. When you have finished and look at your new email in Outlook do not press the send button but use the tools/Macros menu in Outlook to start your send_to_all macro. As you can see from the code the macro will find the currently open email and send that to every recipient.
Back to top
 
 

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
nill
YaBB Newbies
*


I Love SQL*XL

Posts: 0
Re: Outlook: Send same reply to multiple emails.
Reply #5 - 27.10.07 at 01:56:41
 
Hi,
 
Thanks again for replying! Smiley
 
Again, didn't work Sad((
 
I am sure that I am doing something wrong. I know your method should work and it is such a great method that I really want it to work.
 
Here is in detail what I did. Please take special note of No. 5 & 6
1. To start from scratch I deleted the macros from both Outlook and Word.
2. Opened Outlook. From the main window, hit Alt+F11 to open VB editor, insert -> Module, added code there (copy paste from above), saved and closed VB editor.
3. Back to Outlook, clicked new -> mail message (this takes focus off Outlook), composed message
4. Clicked Outlook Tab, went to went to "Sent Items" folder, selected three e-mails using Ctrl (did not open any e-mail in a separate window, only selected)
5. Back to composed message window (e-mail that I want to send), tools -> macro, this DOES NOT not see the "send_to_all" macro (As expected) because it looks in Word
6. Back to main outlook window (the view is "Sent Items" folder with three e-mails selected), tools -> macro, run "send_to_all" (here it DOES see the macro unlike No. 5)
7. ERROR: Run-time error '438': Object doesn't support this proprety or method
LINE of error: Set CurrentItem = ActiveWindow.CurrentItem
 
Please tell what I am doing wrong. I am trying my best to run this, but I mess up everytime Sad
 
Thanks a lot once again!
Back to top
 
 
Email   IP Logged
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 18
Re: Outlook: Send same reply to multiple emails.
Reply #6 - 27.10.07 at 21:32:06
 
Thanks for the detailed information. I tried it myself - I usually don't use Word to write emails. You can set the editor in the Outlook Options.
 
You can indeed not access the Outlook VBA in the window in which you edit the email because that is MS Word now. When you are in MS Outlook the following code line fails:
 
    Set CurrentItem = ActiveWindow.CurrentItem
 
In the ActiveWindow there is no CurrentItem. When Outlook is used to write the email the CurrentItem is the email that you have open at the moment whereas the ActiveWindow.Selection contains the emails you have selected in the folder list. In the code I have published the email in the CurrentItem is duplicated and sent to all the recipients of the selected emails in the Selection list.
 
I don't think you can use the code to send it to everyone. What you can do is to save the email as a draft. Then it is in the drafts folder. You can access it using a statement like this:
 
    Set CurrentItem = Application.GetNamespace("MAPI").Folders("Outlook Today").Folders("Drafts").items("test")
 
Explanation:
The namespace renders to the topmost node in Outlook. Underneath you can have one or more mail stores. My main emails is called Outlook Today. Your's may have a different title. Within the mail store I have selected the Drafts folder and within that the item with subject test. You can use a similar statement to get your email. Note that I tried it using an email that I wrote using Word and then saved as a draft email.
Back to top
 
 

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
nill
YaBB Newbies
*


I Love SQL*XL

Posts: 0
Re: Outlook: Send same reply to multiple emails.
Reply #7 - 27.10.07 at 22:08:32
 
Thank you very much for the prompt reply once again Smiley
 
I tired without Word as the e-mail editor and it WORKED! Smiley
 
I guess I'll just change the e-mail editor whenevr I want to send multiple e-mail and then change back.
 
Thanks once again. Your solution is really cool!
 
I wish you all the best for the future!
 
Best regards!
Back to top
 
 
Email   IP Logged
A K
YaBB Newbies
*


I Love SQL*XL

Posts: 0
Re: Outlook: Send same reply to multiple emails.
Reply #8 - 04.07.08 at 18:05:10
 
Hello Gerrit-Jan,
 
Thanks for this great tip!
 
But it doesn`t work for me either. And it`s not the same problem as stated in this topic (word as email editor)
 
The mails do come on screen, but don`t automaticly send.
If i press ctrl+enter it sends the mail and the next one comes up with the next adress.
 
I tried it using outlook 2003 and outlook XP, but both have the same problem
 
I tried the following to troubleshoot:
 
Sub send_to_all()
    Dim o As MailItem
    Dim CurrentItem As MailItem
    Dim email As MailItem
    Dim lCount As Long
    Dim l As Long
    
    Set CurrentItem = ActiveWindow.CurrentItem
    Set o = ActiveInspector.CurrentItem.Copy
    
    Application.ActiveWindow
    lCount = ActiveExplorer.Selection.Count
    For l = 1 To lCount
      DoEvents
      Set email = ActiveExplorer.Selection.Item(l)
      o.To = email.SenderName
     Shell "notepad", vbNormalFocus
      SendKeys "Test1"

      o.Display True
      SendKeys "%S{ENTER}", True
     Shell "notepad", vbNormalFocus
      SendKeys "Test2"

      Set o = ActiveInspector.CurrentItem.Copy
    Next l
 End Sub
 
To debug i let the macro open up a notepad.
The first one comes up right away, but the second one only comes after manually sending or closing the mail. The problem seems to be in the "o.Display True"
 
I don`t have much VB experience ( i work alot with kix/kixforms.net  Tongue )
 
Do you have any idea what the problem could be?
Pressing ctrl+enter a thousand times is better then reply`ing them all manually, but its no fun  Wink
 
Thanks in advance for your reply.
 
Regards,
Arris Kramer
Netherlands
Back to top
 
 
  IP Logged
Fla441
YaBB Newbies
*


I Love SQL*XL

Posts: 0
Re: Outlook: Send same reply to multiple emails.
Reply #9 - 22.01.11 at 14:21:02
 
Came across this discussion looking for a way to send the same reply to many emails in Outlook 2007.  This is a nice approach to the problem and much better than the other solution one finds searching this problem (i.e., collect the emails in a folder and run a rule to send the replies).  With the method here, you simply compose the reply, select the emails you want to reply to, and run the macro.  
 
Unfortunately, the macro code does not quite work as described in Outlook 2007 since each reply message is displayed with focus and the Send button has to be manually clicked to send each reply.  A quick check of the code showed the problem.  The message does not need to be displayed, and the Send should be handled using the usual method in VBA.  Here is the replacement for the For/Next loop part of the original code.  The replaced lines in the original code are commented out.  With this modification, the reply emails are sent automatically.  
 
For l = 1 To lCount
      DoEvents
      Set email = ActiveExplorer.Selection.Item(l)
      o.To = email.SenderName
      'o.Display True
      o.Display False
      'SendKeys "%S{ENTER}", True
      o.Send
      Set o = ActiveInspector.CurrentItem.Copy
    Next l
 
As a bonus, you can make the macro more accessible.  Add it to your New Message window by opening a new message, right clicking on the quick access toolbar (normally just to the right of the big Office button in Office 2007), select Customize, choose "macros" from the drop down list, select the macro and modify it with a new icon (I picked the double left arrow) and OK.  Now all you have to do is compose your reply (or retrieve it from Drafts), select the emails you want to reply to, then click the icon in the quick access toolbar.
 
Hope this is helpful.
Back to top
 
 
  IP Logged
markroberts
YaBB Newbies
*


I am Confused!

Posts: 0
Re: Outlook: Send same reply to multiple emails.
Reply #10 - 01.09.11 at 15:13:32
 
Please excuse me on this... I had not really looked at the errors reported above so I assume that I have fallen into the same hole.  However I dont quite understand how to change the editor away from MS Word... but I will try the solution mentioned above by saving a draft email in a known location as sugested by Gerrit-Jan. I have left the original message below for completeness as I try and make this work.
 
Cheers....
 
 
 
 
I must be doing soemthing wrong so I hope that someone can assist...
 
Here is the code I am using: (Based on the emails above)
 
Sub send_to_all()
    Dim o As MailItem
    Dim CurrentItem As MailItem
    Dim email As MailItem
    Dim lCount As Long
    Dim l As Long
      
    Set CurrentItem = ActiveWindow.CurrentItem
    Set o = ActiveInspector.CurrentItem.Copy
      
    Application.ActiveWindow
    lCount = ActiveExplorer.Selection.Count
    For l = 1 To lCount
      DoEvents
      Set email = ActiveExplorer.Selection.Item(l)
      o.To = email.SenderName
      'o.Display True
      o.Display False
      'SendKeys "%S{ENTER}", True
      o.Send
      Set o = ActiveInspector.CurrentItem.Copy
    Next l
 End Sub
 
However the instructions for initiating must be my down fall because I get the error  
 
Run time error 438
 
Object does not support this property or method
 
And when I go into the de-bugger the line:
 
Set CurrentItem = ActiveWindow.CurrentItem
 
Is highlighted.
 
But before anyone responds can I summarise what I am trying to do...
 
I want to reply to a whole bunch of emails with a standard response.
 
So I assume one selects the emails you want to respond to once you have written an email with NO to: address filled in...
 
Then you go to the run macro screen and select send_to_all... Well thats what I am doing but I guess I am doing something wrong.
 
Can anybody assist me on this?
 
Cheers
 
Back to top
 
« Last Edit: 01.09.11 at 15:26:20 by markroberts »  
  IP Logged
markroberts
YaBB Newbies
*


I am Confused!

Posts: 0
Re: Outlook: Send same reply to multiple emails.
Reply #11 - 01.09.11 at 15:49:25
 
I have now tried (see above) this Macro and am getting the following error:
 
The operation failed...... The object could not be found.
 
on this line:
 
Set CurrentItem = Application.GetNamespace("MAPI").Folders("Drafts").Items("Test")
 
 
I think the problem is what I have called the top level folder... I am connected to Exchange Server and this means the Mailbox looks like the attached screen grab.. Can someone assist in telling me what I should be doing to describe where the Test email resides?
 
 
 
I have a draft email with the subject of Test filed in a folder called Drafts  which is a sub folder of Mailbox. I notice that Gerrit-Jan that you have a folder called Outlook Today... See attached file for my Folder Structure.
 
 
Cheers
Back to top
« Last Edit: 01.09.11 at 16:03:19 by markroberts »  

Outlook_Query.png
  IP Logged
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 18
Re: Outlook: Send same reply to multiple emails.
Reply #12 - 01.09.11 at 16:17:58
 
Drafts folder
 
You cannot access the drafts folder using:  
Set CurrentItem = Application.GetNamespace("MAPI").Folders("Drafts").Items("Test")  
 
You need to use the GetDefaultFolder function and the parameter olFolderDrafts
 
Example:
 
Public Sub test()
    Dim ns As NameSpace
    Dim fld As folders
    Dim mit As MailItem
     
    Set ns = Application.GetNamespace("MAPI")
    Set fld = ns.GetDefaultFolder(olFolderDrafts)
    Set mit = fld.Item(2)
End Sub
Back to top
 
 

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
markroberts
YaBB Newbies
*


I am Confused!

Posts: 0
Re: Outlook: Send same reply to multiple emails.
Reply #13 - 01.09.11 at 16:38:07
 
Gerrit-Jan - Thank you but as I am not a VB Programmer I really dont understand your reply.
 
In an earlier posting you said.....
 
I don't think you can use the code to send it to everyone. What you can do is to save the email as a draft. Then it is in the drafts folder. You can access it using a statement like this:  
 
    Set CurrentItem = Application.GetNamespace("MAPI").Folders("Outlook Today").Folders("Drafts").items("test")  
 
Explanation:  
The namespace renders to the topmost node in Outlook. Underneath you can have one or more mail stores. My main emails is called Outlook Today. Your's may have a different title. Within the mail store I have selected the Drafts folder and within that the item with subject test. You can use a similar statement to get your email. Note that I tried it using an email that I wrote using Word and then saved as a draft email.

 
 
I just want to know what code I put into your macro to pick up this email to send to the collection of people. I dont mind which folder I put the email in if the Draft folder causes a problem.
 
Kind regards
 
I just dont follow your latest response at all.. I am so sorry
Back to top
 
 
  IP Logged
Pages: 1