Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / September 2007

Tip: Looking for answers? Try searching our database.

Access 2000 / Outlook 2007

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bh - 17 Sep 2007 19:18 GMT
I'm trying to email from Access 2000 using the following:

   Dim objOutlook As Outlook.Application
   Dim objOutlookMsg As Outlook.MailItem
   Dim objOutlookRecip As Outlook.Recipient
   Dim objOutlookAttach As Outlook.Attachment

   Set objOutlook = CreateObject("Outlook.Application")
   Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

   With objOutlookMsg
           Set objOutlookRecip = .Recipients.Add("Email addresses separated
by semicolons")
           objOutlookRecip.Type = olTo
           .Subject = "Whatever subject"
           .Body = "Whatever message text"
          For Each objOutlookRecip In .Recipients
              objOutlookRecip.Resolve
          Next
          .Display
   End With

   Set objOutlook = Nothing
   SendMessage = True

This process always worked fine with Outlook 2000 and then Outlook 2003;
however, in Outlook 2007, I get an Error 287 (Object definition error).  I
was using Outlook Library 11.0, previously, but now some users are using
Outlook 2007 instead of '03.  When I put the program on a machine with 2007,
however, the Library 12.0 is showing as referenced in my code-behind
(appearing to have grabbed automatically)...  The machine I actually
developed the app on has Outlook 2003, and only some of the users will have
2007, and I manually had chosen the 11.0 library.  Any ideas on how to
resolve this would be helpful.
Sue Mosher [MVP-Outlook] - 17 Sep 2007 19:34 GMT
[non-developer newsgroup removed]

You didn't say which statement raises the error. If you get an error from code statements like these:

   Dim ol as New Outlook.Application

   Set ol = CreateObject("Outlook.Application")

the cause may be an anti-virus program on your computer that has a feature to block Outlook scripting. If so, the solution is to turn off the script blocking feature. You may need to contact technical support for your anti-virus program to find out how to do that.

I've also seen reports that setting the server parameter can resolve this problem in some situations:

   Set ol = CreateObject("Outlook.Applicaton", localhost)

Signature

Sue Mosher, Outlook MVP
  Author of Microsoft Outlook 2007 Programming:
    Jumpstart for Power Users and Administrators
   http://www.outlookcode.com/article.aspx?id=54

> I'm trying to email from Access 2000 using the following:
>
[quoted text clipped - 30 lines]
> 2007, and I manually had chosen the 11.0 library.  Any ideas on how to
> resolve this would be helpful.
Tim Freeman - 18 Sep 2007 19:56 GMT
I tried similar code:
   Set objOutlook = CreateObject("Outlook.Application")
   Set objOlns = objOutlook.GetNamespace("MAPI")
   
   Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
   If Len(lsEmailAddress) > 0 Then
       objOutlookMsg.Recipients.Add lsEmailAddress
   End If

It failed if I did not have Outlook open but works fine with Outlook open.

> [non-developer newsgroup removed]
>
[quoted text clipped - 44 lines]
> > 2007, and I manually had chosen the 11.0 library.  Any ideas on how to
> > resolve this would be helpful.
Sue Mosher [MVP-Outlook] - 18 Sep 2007 21:02 GMT
You didn't say which statement fails.

If Outlook is not already running, then you may need to use a Namespace.Logon statement to start Outlook with a specific profile or allow the user to choose the mail profile.

Signature

Sue Mosher, Outlook MVP
  Author of Microsoft Outlook 2007 Programming:
    Jumpstart for Power Users and Administrators
   http://www.outlookcode.com/article.aspx?id=54

>I tried similar code:
>    Set objOutlook = CreateObject("Outlook.Application")
[quoted text clipped - 55 lines]
>> > 2007, and I manually had chosen the 11.0 library.  Any ideas on how to
>> > resolve this would be helpful.
Tim Freeman - 19 Sep 2007 10:24 GMT
Thanks Sue, I was replying to BH as to why the code failed but mine failed
on the objOutlookMsg.Recipients.Add lsEmailAddress statement. It quite
happily creates the email and displays it afterwards  but unless the user is
logged in, the recipient cannot be created.

Regards

> You didn't say which statement fails.
>
[quoted text clipped - 59 lines]
> >> > 2007, and I manually had chosen the 11.0 library.  Any ideas on how to
> >> > resolve this would be helpful.
Sue Mosher [MVP-Outlook] - 19 Sep 2007 13:32 GMT
Outlook should be able to resolve IsEmailAddress to a recipient if it is a straight SMTP address, but if you're passing a name that has to be resolved, a login is necessary. Otherwise, Outlook may not know what address lists are available for name resolution. You can add an objOlns.Login statement to either use a specific profile or prompt the user to choose one.

Signature

Sue Mosher, Outlook MVP
  Author of Microsoft Outlook 2007 Programming:
    Jumpstart for Power Users and Administrators
   http://www.outlookcode.com/article.aspx?id=54

> Thanks Sue, I was replying to BH as to why the code failed but mine failed
> on the objOutlookMsg.Recipients.Add lsEmailAddress statement. It quite
[quoted text clipped - 10 lines]
>> >
>> > It failed if I did not have Outlook open but works fine with Outlook open.
Tim Freeman - 19 Sep 2007 22:56 GMT
> Outlook should be able to resolve IsEmailAddress to a recipient if it is a straight SMTP address, but if you're passing a name that has to be resolved, a login is necessary. Otherwise, Outlook may not know what address lists are available for name resolution. You can add an objOlns.Login statement to either use a specific profile or prompt the user to choose one.
>
[quoted text clipped - 12 lines]
> >> >
> >> > It failed if I did not have Outlook open but works fine with Outlook open.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.