send email with outlook closed

  • Thread starter Thread starter Abbarition
  • Start date Start date
A

Abbarition

I have an Access 2000 file that needs to send out an
email through Outlook 2000. The code I am using is as
follows:
Dim objOl As Object
Dim oItem As Object
Set objOl = CreateObject("Outlook.Application")
Set oItem = objOl.createItem(olmailitem)
With oItem
... etc.

It works fine, but I receive an Internal Application
Error if Outlook is not open. I recently saw the
following code here:
Dim OLF as Outlook.MAPIFolder
Dim olMailItem as Outlook.MailItem
Set OLF = GetObject
("", "Outlook.Application").GetNamespace
("MAPI").GetDefaultFolder(olFolderInbox)
Set olMailItem = OLF.Items.Add
With olMailItem
... etc.

However, I receive errors saying I don't have enough
memory when I try to use .Attachments.Add with this
code. Is there a way to either modify the first code so
it opens Outlook (if it's not open), or modify the second
code to use less memory?

Thanks!
 
After the line
Set objOl = CreateObject("Outlook.Application")
try to add 2 more lines:
set objNS = objOl.GetNamespace("MAPI")
objNS.Logon

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool
 
That works beautifully. Thanks so much!
-----Original Message-----
After the line
Set objOl = CreateObject("Outlook.Application")
try to add 2 more lines:
set objNS = objOl.GetNamespace("MAPI")
objNS.Logon

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool





.
 
Back
Top