PDA

View Full Version : Late Binding Sending Outlook Email



Mavila
01-02-2013, 10:03 PM
I'm must trying a simple bit of code but I'm stymied. The code runs through without any errors but nothing happens. I know I've done it before and have got it working. What am I missing? Thanks for any insight!


Dim olApp As Object
Dim olMail As Object

On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If Error = 429 Then
Set olApp = CreateObject("Outlook.Application")
End If

olApp.Visible = True

Set olMail = olApp.CreateItem(0)
With olMail
.To = "name@domain.com"
.Subject = "Safety Designs Feedback"
.Display
End With
Set olMail = Nothing
Set olApp = Nothing

BrianMH
01-03-2013, 01:32 AM
Works fine for me. Are you running this in outlook or another application? Have you set the appropriate references?

Mavila
01-03-2013, 07:58 AM
Works fine for me. Are you running this in outlook or another application? Have you set the appropriate references?

Hi Brian and thanks for the response.

I'm running it from Word. I thought with "late binding" you didn't need a reference to Outlook 14.0 Object Library. I thought that's what the late binding method does?

Anyway, it doesn't work either way, though. It doesn't matter if I have the Outlook 14.0 Object Library chosen as a reference through tools or not. It does the same thing (nothing) either way.

BrianMH
01-03-2013, 08:19 AM
Hmm.

Works for me even with the reference not set. The mail does go behind the current window but it works just fine.

Perhaps you need to modify your security settings?

Mavila
01-03-2013, 08:35 AM
Hmm.

Works for me even with the reference not set. The mail does go behind the current window but it works just fine.

Perhaps you need to modify your security settings?

As in Windows or Anti-Virus software?

BrianMH
01-03-2013, 08:54 AM
I meant more along the lines of macro security. I'm no expert but I believe in order to stop viruses sometimes automation of outlook is pretty restricted.

Mavila
01-05-2013, 09:43 AM
That was it, Brian. Thanks!

BrianMH
01-06-2013, 05:54 AM
Glad to help! Make sure to mark the thread as solved.