A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Late binding code



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4  
Old May 13th 08, 03:12 PM posted to microsoft.public.access,microsoft.public.outlook,microsoft.public.outlook.program_vba
Norman Yuan
external usenet poster
 
Posts: 14
Default Late binding code

You are right, I missed olMailItem.

"Douglas J. Steele" wrote in message
...
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





 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Late binding code John[_11_] Outlook - General Queries 5 May 13th 08 03:12 PM
binding... Jonathan Outlook and VBA 10 July 17th 07 09:48 PM
Early binding and late binding with attachment Jonathan Outlook and VBA 2 June 9th 06 02:24 AM
Late binding sample John Outlook - General Queries 3 February 24th 06 09:32 PM
Late binding sample John Outlook and VBA 3 February 24th 06 09:32 PM


All times are GMT +1. The time now is 11:37 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.