Outlook Macro to autoreply all mails in a folder.

Hi,

Outlook Macro to autoreply all mails in a folder.
I have a folder in outlook that has say about 2000+ mails that i received details from the employees.I need a macro that can reply each mail with a data. " Thanks the data has been update"
This data has to be sent to each mail i received.Is there a easy way in doing this.

Regards
Sharath
LVL 11
bsharathAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
David LeeConnect With a Mentor Commented:
Sharath,

The code below will do the job.  Select one or more messages in a folder and run the macro.  It'll reply to every message selected.  If you want to reply to all messages in a folder, then use CTRL+A to select them all.

Keep in mind that sending messages from code is going to trigger Outlook's built-in security.  Outlook will display a dialog-box warning that a program is trying to send a message and ask for your permission to allow it to continue.  That's going to happen for each message.  Outlook security can't be turned off, but there are third-party workarounds: Outlook Redemption (http://www.dimastr.com) and Click-Yes (http://www.contextmagic.com/express-clickyes).  
Sub ReplyToAllSelected()
    Const REPLY_TEXT = "Thanks the data has been updated."
    Dim olkMsg As Object, _
        olkReply As Object
    For Each olkMsg In Application.ActiveExplorer.Selection
        Set olkReply = olkMsg.Reply
        If olkReply.BodyFormat = olFormatHTML Then
            olkReply.HTMLBody = REPLY_TEXT & "<br><br>" & olkReply.HTMLBody
        Else
            olkReply.Body = REPLY_TEXT & vbCrLf & vbCrLf & olkReply.Body
        End If
        olkReply.Send
    Next
    Set olkMsg = Nothing
    Set olkReply = Nothing
    MsgBox "All done!", vbInformation + vbOKOnly, "Reply to All Selected"
End Sub

Open in new window

0
 
SolutionsCSCommented:
You can use an autoreply to answer message at there reception.  Or you can write a macro to read an existing folder and reply to every message in the folder of your needs.
0
 
bsharathAuthor Commented:
Autoreply would not be fine as i already have these in the folder.Can you help with a macro to do this...
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
SolutionsCSCommented:
Here is a bit of code to do this


Sub ReplytoALLEmail()
    Dim objFolder As Folder
    
    Dim objTemplate As MailItem
    Set objTemplate = Application.ActiveExplorer.Selection.Item(1)
    
    Set objFolder = objTemplate.Parent
    
    Dim objItem As MailItem
    Dim objReply As MailItem
    
    Dim dic As New Dictionary
    
    Dim strEmail As String
    
    Dim strEmails As String
    
    Dim strBody As String
    strBody = objTemplate.Body
    
    For Each objItem In objFolder.Items
        If Not (objTemplate = objItem) Then
        
            strEmail = objItem.SenderEmailAddress
            
            If Not dic.Exists(strEmail) Then
                strEmails = strEmails + strEmail + ";"
                
                dic.Add strEmail, ""
                
                Set objReply = objItem.Reply()
                
                objReply.Body = strBody + vbCrLf + vbCrLf + objItem.Body
                
                On Local Error Resume Next
                objReply.Send
            End If
        End If
        
    Next
    
    Debug.Print strEmails
End Sub

Open in new window

0
 
bsharathAuthor Commented:
Thanks Should i select the folder or mails to execute these.
Where should i mention the reply details.
0
 
SolutionsCSCommented:
Actually the content of the reply is issue from a selected message when this macro is called.
  Set objTemplate = Application.ActiveExplorer.Selection.Item(1)

You have to replace this with your reply or whatever else to achieve your goal.
objReply.Body = " Your content"
0
 
bsharathAuthor Commented:
Will the mails go to all the users in the folder that i select.
Please give me the clear picture how this works.I dont want to be sending replys to lakhs of persons whose mails i have in the inbox and other folders...
0
 
SolutionsCSCommented:
Tomorrow, i'll do it for you.  Now i have to sleep.  Thanks for waiting
0
 
bsharathAuthor Commented:
Any help...
0
 
bsharathAuthor Commented:
Any help...
0
 
bsharathAuthor Commented:
Thanks a lot... Excellent help... ;-)
0
 
David LeeCommented:
You're welcome, Sharath.
0
 
bsharathAuthor Commented:
BlueDevilFan

If time permits please look at the other posts on outlook .....
0
 
bsharathAuthor Commented:
Hi David,
 Can you please help with this post.
http://www.experts-exchange.com/Software/Office_Productivity/Groupware/Outlook/Q_23614898.html
its the same post here with a little more additions required...
0
All Courses

From novice to tech pro — start learning today.