View Single Post
  #2  
Old October 29th 06, 02:18 AM posted to microsoft.public.outlook
Darren
external usenet poster
 
Posts: 12
Default keystroke for sending mail...

Click on tools, macor, and then Visual Basic Editor

Create a new Module. You can keep the default name of Module1, but I
recommed you change it. Do not name the module the same name as the
sub.

Post the following code to your macro.

Sub Sendmailthiscontact()

' This macro will send an email to an open contact
On Error GoTo Endlable
Dim ns As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder
Dim Item As Object
Dim strContactInfo As String
Dim dataObject As MSForms.dataObject

' ------------------------------------------------------------------
' This portion of macro was created to obtain the email address from
the open contact
' If you do not have an opend contact, the macro will fail.
' ------------------------------------------------------------------

Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.ActiveInspector.CurrentItem

If myItem.Email1Address "" Then
strContactInfo = myItem.Email1Address
End If

' ------------------------------------------------------------------
' This portion of macro opens a new mail item
' ------------------------------------------------------------------

Set myItem2 = myOlApp.CreateItem(olMailItem)
Set myRecipient = myItem2.Recipients.Add(strContactInfo)
myItem2.Display

Endlable:
Set myNameSpace = Nothing
Set myFolder = Nothing
Set myItem = Nothing
Set myItem2 = Nothing

End Sub

Ads