how to add email address to outlook

  • Thread starter Thread starter moosecoyotebear
  • Start date Start date
From Word?

Sub AddOutlookCont()
Dim ol As New Outlook.Application
Dim ci As ContactItem
Dim strAddress As String
Dim strFullName As String

strAddress = Selection.Range
iResult = MsgBox("Is the email address correct?" & _
vbCr & vbCr & strAddress, vbYesNo, "Address")
If iResult = 7 Then GoTo UserCancelled:

name:
strFullName = InputBox("Enter contact's name" _
& vbCr & "in the format 'Mr. John Smith", "Contact name")

On Error GoTo UserCancelled:

Set ci = ol.CreateItem(olContactItem)
If strFullName <> "" Then
ci.FullName = strFullName
Else
MsgBox "Name cannot be left blank"
GoTo name:
End If
ci.FileAs = strFullName
ci.Email1Address = strAddress
ci.Save
' ol.Quit
Set ol = Nothing
Exit Sub
UserCancelled:
MsgBox "User Cancelled or address not selected"
Set ol = Nothing
End Sub

http://www.gmayor.com/installing_macro.htm
--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top