LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Creating a MailItem in Outlook from Excel using Late Binding

Hi there, thanks for your Attention !! Excel 2002, WinXP

I have problems with the Following Code, copied from the excellent site
http://www.dicks-clicks.com, with some changes introduced by me.

I want to use Late Binding.

The problem is with the line:

Set olMail = olApp.CreateItem(olMailItem),

which gives Compile Error "Variable not Defined".

The previous line:
Set olNs = olApp.GetNamespace("MAPI")
I left in the code without really undestanding what I need it for...

Following is the Code, and Really thanks for your time !!!
Steven Kelder

Sub SendResults()
Dim olApp As Object
Dim olNs As Object
Dim olMail As Object 'Late Binding-generic Object data type

'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

Set olNs = olApp.GetNamespace("MAPI") 'Do I need this ??
Set olMail = olApp.CreateItem(olMailItem)

'Send Mail:
With olMail
.To = "
.Subject = "Sample Subject"
.Body = "Sample Body Text" & vbCrLf
.Send
End With

Set olNs = Nothing
Set olApp = Nothing
End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Late Binding issue with Excel.Application object [email protected][_2_] Excel Discussion (Misc queries) 2 August 4th 09 08:10 AM
Late binding to Excel from Access causing Object error EagleOne@microsoftdiscussiongroups[_2_] Excel Discussion (Misc queries) 4 June 14th 08 12:45 AM
VB Extensibility library and "late binding" Dennis Excel Discussion (Misc queries) 0 March 30th 05 10:51 PM
Early vs Late Binding - Word John Wilson Excel Programming 6 November 13th 03 03:21 PM
DAO objects with late binding in Excel? Chris Excel Programming 0 August 21st 03 07:28 PM


All times are GMT +1. The time now is 02:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"