Hi,
A little while ago I asked if anyone could help me with how to create an
email using MS Outlook that contained an embedded picture file.
Thanks to Jay Harlow I was able to get this working using a code example
from http://www.outlookcode.com/d/code/htmlimg.htm that details the
procedure and with a bit of tweaking I managed to get it working really
well.
I now find that there is a new user on a laptop that always gets an error at
the point where the code creates an Outlook object. I have included all the
interop DLLs with the application and for all users, the code works, except
this one.
The code snippet that is having the problem is:
' Outlook objects
Dim objApp as Outlook.Application
Dim l_Msg As MailItem
Dim colAttach As Outlook.Attachments
Dim l_Attach As Outlook.Attachment
Dim oSession As MAPI.Session
' CDO objects
Dim oMsg As MAPI.Message
Dim oAttachs As MAPI.Attachments
Dim oAttach As MAPI.Attachment
Dim colFields As MAPI.Fields
Dim oField As MAPI.Field
Dim strEntryID As String
' create new Outlook MailItem
Set objApp = CreateObject("Outlook.Application","") '<== PROBLEM OCCURS
HERE!!
Set l_Msg = objApp.CreateItem(olMailItem)
' add graphic as attachment to Outlook message
' change path to graphic as needed
Set colAttach = l_Msg.Attachments
Set l_Attach = colAttach.Add("c:\test\graphic.jpg")
l_Msg.Close olSave
strEntryID = l_Msg.EntryID
Set l_Msg = Nothing
etc ...
The user has the same DLLs installed in the application folder as all the
other users, the difference is that they all had MS Office 2000 and then
upgraded to Outlook 2003 as part of the Small Business Server 2003
installation, where the new user only ever had Outlook 2003.
I am using the following DLLs:
===============================
DLL Version
Interop.MAPI.dll 1.21.0.0
Interop.Microsoft.Office.Core.dll 2.3.0.0
Interop.Outlook.dll 9.2.0.0
================================
Can anyone explain why the CreateObject command is failing on that one
machine? It's driving me nuts!
--
Siv
Martley, Near Worcester, UK.