View Single Post
  #3  
Old May 13th 08, 01:17 AM posted to microsoft.public.access,microsoft.public.outlook,microsoft.public.outlook.program_vba
Douglas J. Steele
external usenet poster
 
Posts: 3
Default Late binding code

Not quite. olMailItem is defined in the Outlook library, so you need to
provide a value for the constant:

Set EM = OutlookApp.CreateItem(0)

or

Const olMailItem As Long = 0

Set EM = OutlookApp.CreateItem(olMailItem)


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"Norman Yuan" wrote in message
...
Dim OutlookApp As Object
Dim EM As Object

On Error Resume Next
Set OutlookApp = GetObject(,"Outlook.Application")
If Err.Number0 Then
Err.Clear
Set OutlookApp=CreateObject("Outlook.Application")
If Err.Number0 Then
MsgBox "Cannot get Outlook"
Exit Sub
End If
End If

OutlookApp.GetNamespace("MAPI").Logon

Set EM = OutlookApp.CreateItem(olMailItem)

With EM
.To = "
.HTMLBody = "Something here..."
.Attachments.Add a(I)
.Display (False)
End With

Of course you'll remove reference to Outlook object library and


"John" wrote in message
...
Hi

I have the below code to send an email from within MS Access using
Outlook. What would be the late binding version of this code?

Many Thanks

Regards


Dim OutlookApp As Outlook.Application
Dim ns As Outlook.NameSpace
Dim EM As Outlook.MailItem

Set OutlookApp = New Outlook.Application

Set ns = OutlookApp.GetNamespace("MAPI")
ns.Logon

Set EM = OutlookApp.CreateItem(olMailItem)

With EM
.To = "
.HTMLBody = "Something here..."
.Attachments.Add a(I)
.Display (False)
End With

Set EM = Nothing




Ads
 

Free Ringtones - Credit Cards - Cell Phones - Personal Loans - Finance