Hi,
I have some code that calls Outlook. Unfortunatley I have to write the code
on a pc with OL2003, but the PC that it will run on is OL2002 (and so the
reference needs to be Outlook 10.0 not 11.0). I can't change the reference
on the pc that it will run on, so I think i need to remove the reference and
use late binding, but I'm struggling. My code is below, what changes do I
need to make?
Public Sub EmailImage(FName As String)
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
On Error Resume Next
Set oOutlookApp = GetObject(, "Outlook.Application")
If Err <> 0 Then
MsgBox ("There has been a problem connecting to your email
account and the mail will not be sent")
Exit Sub
End If
Set oItem = oOutlookApp.CreateItem(olMailItem)
With oItem
.To = "a@b.com"
.subject = "***FILEONLY***"
.Attachments.Add Source:=FName
.body = "Please scan the attached document as FILEONLY"
.BodyFormat = olFormatPlain
.Send
End With
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub
Jonathan West - 01 Jul 2007 01:10 GMT
> Hi,
>
[quoted text clipped - 33 lines]
>
> End Sub
With any luck, you need only change two lines. Change this
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
to this
Dim oOutlookApp As Object
Dim oItem As Object
The essence of late binding is that you declare your variables As Object,
and it is only when they are first assigned that the program knows what sort
of object they are. The advantage is being able to deal with multiple
versions, the disadvantage is that you lose type-checking when writing the
code.

Signature
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup