PDA

View Full Version : Macro for replies to emails



wp8800
05-09-2011, 12:29 AM
Hi everyone, would really appreciate some help with a code for outlook 2007

Basically im looking to create several macros which i can then use to send specific replies to emails.

i.e.

email comes in to my inbox, i hit macro '1' button on toolbar, and outlook will send a pre specified reply to that person, from my correct email address (i have several which all poll to outlook)

I want to have different replies on different toolbar buttons, so i can just hit the button for the particular reply i want to send and get outlook to send it.

is this possible? is it possible to write a code for it, and advise how i can change it for each reply?

many thanks for any help

cheers


Wayne

wp8800
05-11-2011, 02:03 AM
could anyone even push me in the right direction?

Benzadeus
05-20-2011, 12:33 PM
Do you know hot to create a button?
Create several buttons and then, in each one, do something like this:

Use this little snippet to determine the account number you want to send the e-mail:
Sub Which_Account_Number()
Dim OutApp As Outlook.Application
Dim I As Long

Set OutApp = CreateObject("Outlook.Application")

For I = 1 To OutApp.Session.Accounts.Count
MsgBox OutApp.Session.Accounts.Item(I) & " : This is account number " & I
Next I

End Sub

So, use something like this:

Sub Button1()
Call HitButton(1)
End Sub

Sub Button2()
Call HitButton(2)
End Sub

'... and son on

Sub HitButton(l As Long)

Dim ml As MailItem

Set ml = CreateItem(olMailItem)

With ml
Select Case l
Case 1
.To = "guy1@example.com"
.SendUsingAccount = Session.Accounts.Item(1)
.Body = "text here 1"
Case 2
.To = "guy2@example.com"
.SendUsingAccount = Session.Accounts.Item(1)
.Body = "text here 2"
'and so on Case 3, Case 4...
End Select
.Send 'or .Display
End With

End Sub