>> Early binding and late binding with attachment

J

Jonathan

Hi, in MS Access I have the following procedure...

Set objMail = objOutlook.CreateItem(olMailItem)
With objMail
.To = BAE![aEmail]
.subject = BAE![AnaesName] & "'s List"
.Attachments.Add source:=strFile & ".doc", Type:=olByValue,
Position:=1, DisplayName:="Booking List"
.Display
End With

This works fine when the Outlook object library is referenced and each
object is explicitly declared as the Outlook type. For example
Dim objMail as Outlook.MailItem

The problem is that at least one user does not have the same version of MS
Office. So I cannot reference a specific Outlook object library and I declare
each object variable as Object. For example
Dim objMail as Object

I declare each of the Outlook constants as constants.
Const olMailItem As Integer = 0
Const olByValue As Integer = 1

The problem is that when declaring each object as object the line to attach
a file no longer works. There is no error message and no attached file.

Any ideas or suggestions that will assist me to use late binding are
appreciated. :)

Many thanks
Jonathan
 
S

Sue Mosher [MVP-Outlook]

Have you tried using positional parameters rather than named parameters?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
J

Jonathan

Thanks Sue, problem solved

Cheers
Jonathan Parminter

Sue Mosher said:
Have you tried using positional parameters rather than named parameters?

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers


Jonathan said:
Hi, in MS Access I have the following procedure...

Set objMail = objOutlook.CreateItem(olMailItem)
With objMail
.To = BAE![aEmail]
.subject = BAE![AnaesName] & "'s List"
.Attachments.Add source:=strFile & ".doc", Type:=olByValue,
Position:=1, DisplayName:="Booking List"
.Display
End With

This works fine when the Outlook object library is referenced and each
object is explicitly declared as the Outlook type. For example
Dim objMail as Outlook.MailItem

The problem is that at least one user does not have the same version of MS
Office. So I cannot reference a specific Outlook object library and I declare
each object variable as Object. For example
Dim objMail as Object

I declare each of the Outlook constants as constants.
Const olMailItem As Integer = 0
Const olByValue As Integer = 1

The problem is that when declaring each object as object the line to attach
a file no longer works. There is no error message and no attached file.

Any ideas or suggestions that will assist me to use late binding are
appreciated. :)

Many thanks
Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top