PDA

View Full Version : Sending Specific E-mail



jim hopper
06-13-2012, 11:48 AM
Hi,

I am new to VBA and I wonder if someone could help me with Outlook.

On receiving a specific type of e-mail I would like to send the e-mail back to the sender with a specific message embedded in the body of the e-mail to try and stop them sending the e-mail again.

I would like to make this an automated as posiible as people using this are not fully IT literate,

My idea would be that the user opens the email sees its for sending back and clicks on a button on the tool bar (if possibel) which immeadiately returns the e-mail to the sender with an instructional message in the body of the e-mail

Thanking you all in advance

Jim

BrianMH
06-14-2012, 12:26 AM
You could use outlook rules for that.

jim hopper
06-17-2012, 10:30 AM
Hi,

Thanks for the response but is your resonse affected by the fact that we use Outlook enterprise edition (2003)

My think is that I cpould press a button whic would attche the current selected e-mail (having identified that it contained the required information in the body of the e-mail) to a predefined template and then send it

Again thanking you all in advance

Jim

JP2112
06-21-2012, 10:58 AM
Is it the same instructional message each time? You could use something like

Sub ReplyWMessage()

Dim replyMsg As Outlook.MailItem

Const INSTRUCTIONAL_MESSAGE As String = _
"Listen buddy, I've had enough. Stop sending me this junk or I'll be forced to: " & _
"(a) kidnap your pets and donate them to medical science, " & _
"(b) draw the letter 'X' on your door in chalk so someone in a Guy Fawkes mask kills you, or " & _
"(c) make you vote for Hillary Clinton."

Set replyMsg = ActiveExplorer.Selection.Item(1).Reply

With replyMsg
.Body = INSTRUCTIONAL_MESSAGE & vbNewLine & .Body
.Send
End With

End Sub

Attach this to a toolbar button, select the message and then click the button to send the reply.

jim hopper
06-21-2012, 12:17 PM
JP,

Thanks for that I will try it on Monday and let you know the outcome

Many thanks again

Jim

jim hopper
06-26-2012, 12:14 PM
JP,

I have tested the code and it works perfectly. The only caveats is that Outlook asked you to allow user access to e-mail and then asks you to confirm e-mail send. However I can live with that

Thanks again for the help

I will use this to help me to progress my knowledge