I want to write a macro to type a series of keystrokes before i send out an email

53 Views Asked by At

I currently have a .oft template that i use when sending an email to a customer with a quote attached. It includes some highlights of the quote. For example number of days, etc. What am i currently doing manually is typing the following keystrokes CTRL+A, ALT, O, I, N, ALT, P, PC, N. Which basically turns off highlighting for the whole document and removes the watermark. The watermark is a textual visual reminder to make sure the quote is attached as well as another document.

Can anyone get me started on a macro for this?

I haven't' tried anything yet as i don't know where to start. What i am trying to accomplish is for all highlighting to go away, as well as the watermark. Both of these are used as visual reminders to check an often-changing part of the email or add an attachment.

1

There are 1 best solutions below

2
Eugene Astafiev On

You need to handle the ItemSend event of the Outlook Application class to handle outgoing emails in Outlook, for example:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)  
 Dim prompt As String  
 prompt = "Are you sure you want to send " & Item.Subject & "?"  
 If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then  
   Cancel = True  
 End If  
End Sub

See Getting started with VBA in Office as a starting point.

Also you may find the article I wrote for the technical blog a decade ago helpful - How To: Change an Outlook e-mail message before sending using C# or VB.NET.