Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error creating outlook email

Status
Not open for further replies.

JTBorton

Technical User
Jun 9, 2008
345
DE
I am having trouble opening a blank email message from excel. When I try and run it I get the following error message:

[!]Run-time error '-2113732605 (82030003)'
Automation error[/!]

Code:
[COLOR=darkblue]Dim[/color] olApp [COLOR=darkblue]As[/color] Outlook.Application
[COLOR=darkblue]Dim[/color] olMail [COLOR=darkblue]As[/color] Outlook.MailItem, olSendTo [COLOR=darkblue]As[/color] Outlook.Recipients

    [COLOR=green]'open Outlook[/color]
    [COLOR=darkblue]Set[/color] olApp = CreateObject("Outlook.Application")
        
    [COLOR=green]'Create mail message[/color]
    [COLOR=darkblue]Set[/color] olMail = olApp.CreateItem(olMailItem)[tab][!]<-- Error Here[/!]
    
    [COLOR=darkblue]With[/color] oMailItem
        [COLOR=darkblue]Set[/color] olSendTo = .Recipients.Add("Staff")
        olSendTo.Type = olTo
        .Subject = sSubject
    [COLOR=darkblue]End With[/color]
    olMail.Display
Can anyine tell me what I am doing wrong?
 
I have an application that creates an olTaskItem.

Except it wouldn't work with set mytask = olApp.CreateItem(olTaskItem)

I had to use set mytask = olApp.CreateItem(3)

So, try a number instead of "olMailItem" and see what happens.
 
I've used the same code, and the only difference is I didn't explicitly reference the mail item as an Outlook.mailitem.

I'm looking at code right now that works, and here is part of it:

Code:
Dim olApp As Outlook.Application
Dim olMail As MailItem
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)

Tyrone Lumley
SoCalAccessPro
 
Both solutions worked perfectly. Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top