VBA code for automatically replying to emails in Outlook 2010

madmiddle

New Member
Joined
Mar 8, 2012
Messages
45
Afternoon gents,

Could i please have some guidance on the following macro.

What i would like it to is reply to the email selected with a personalise template.

Here is the code i have at the moment.
Code:
Public Sub software_request()
 Dim oMail  As MailItem
 On Error GoTo blad
 Select Case TypeName(Application.ActiveWindow)
        Case "Explorer":  Set oMail = ActiveExplorer.Selection.Item(1)
        Case "Inspector": Set oMail = ActiveInspector.CurrentItem
 Case Else: Exit Sub
 End Select
 Call software_reply(oMail)
blad:
End Sub

Sub software_reply(Item As Outlook.MailItem)
'MVP OShon from VBATools.pl
If Item <> olMailItem = False Then Exit Sub
Dim oReply As MailItem
With Item
    Set oReply = .Reply
         oReply.Body = "Dear " & .SenderName & vbNewLine & _
         "" & vbNewLine & _
         "Your software request has now been submitted " & vbNewLine & _
         "" & vbNewLine & _
         "Regards" & vbNewLine & _
         "" & vbNewLine & _
         "Andy"
         
        oReply.Display
        'oReply.send 'to send
    Set oReply = Nothing
    
End With
End Sub

at the moment it comes out like this:

Code:
[COLOR=#000000][FONT=Arial]Dear Smith, John (UK)
[/FONT][SIZE=3][FONT=Times New Roman] [/FONT][/SIZE][/COLOR]
[COLOR=#000000][FONT=Arial]Your software request has now been submitted [/FONT][/COLOR]
[COLOR=#000000][FONT=Arial]
Regards[/FONT][SIZE=3][FONT=Times New Roman] [/FONT][/SIZE][/COLOR]
[COLOR=#000000][FONT=Arial]
Andy[/FONT][SIZE=3][FONT=Times New Roman] [/FONT][/SIZE][/COLOR]

which is nearly there but i would like to include the original message either with it attached or in the email its self.

Also if possible i would only like to have the first name in the 'dear' part if that is possible.

I'm on Win XP
Outlook 2010 and it's a corporate email system which is probably why it's come up with the (UK) part
and i got the basic code from here

Thank you very much in advance
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Forum statistics

Threads
1,215,514
Messages
6,125,267
Members
449,219
Latest member
daynle

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