View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dick Kusleika[_3_] Dick Kusleika[_3_] is offline
external usenet poster
 
Posts: 599
Default Creating a MailItem in Outlook from Excel using Late Binding

Steven

You don't need any of the olNs lines to send an email. You generally need
to get to the NameSpace to access items in folders, but not to create items.
So you can delete those lines.



'Activate Outlook if it isn't Open yet:
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")

If Err.Number = 429 Then
Set olApp = CreateObject("Outlook.application")
End If

On Error GoTo 0
'End Activate Outlook


There's no problem with this code, but you don't need all of it just to send
a mail. If you're just sending, you can use

Set olApp = CreateObject("Outlook.Application")

Even if you already have Outlook running, this will create a new instance of
Oultook. No matter how many instances you have, they all use the same pst
files, that is, they all access the same information. So creating a new
instance doesn't matter.

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.