Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Reference Library Problem

Status
Not open for further replies.

AlexCuse

Programmer
Apr 13, 2006
5,416
US
Hi All,

This problem was created the last time I took a day off (IT came in and installed access 2003 on both of my PC's, destroying a lot of functionality in my applications). I have been working overtime to get these apps ready for my next days off, which start today. They are in good shape except for one thing (which obviously won't be fixed until I get back on Friday, so users will be dealing with sending the email manually).

With the new install, access seems unable to find the Outlook reference library. I am really stuck on this one, I had a whole bunch of subs that sent email automatically and none of them work anymore. Any advice you could give on this would be greatly appreciated, although it will not save my users the hassle of sending emails manually the next few days. Thanks in advance for your help, and here is the code if that helps:

Code:
Private Sub EmailYankee_Click()




Dim objOutlook As Outlook.Application
Dim ItmNewEmail As Outlook.MailItem
Dim filedate, fnamedate As String
Dim fdir As String
Dim title               As String
Dim OutputFileName          As String


filedate = Date
fnamedate = Format(filedate, "mmddyy")
OutputFileName = "Reports" & fnamedate & ".zip"
fdir = "some\dir\"

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



With ItmNewEmail
     .To = "emails"
     .CC = "emails"
     .Subject = "Subject" & filedate
     .Body = "Attached please find today's reports.  Please notify (user) if you have any questions." & Chr(13) & Chr(13) & "Thank You."
     .Attach = fdir & OutputFileName
     

     .Send                                                ' send files and notification
End With





End Sub

It's a magical time of year in Philadelphia.  Eagles training camp marks the end of another brutal season of complaining about the Phillies.
 
I wonder would late binding help?
Code:
[blue]Dim objOutlook As Object 'Outlook.Application
Dim ItmNewEmail As Object 'Outlook.MailItem[/blue]
Dim filedate, fnamedate As String
Dim fdir As String
Dim title               As String
Dim OutputFileName          As String


filedate = Date
fnamedate = Format(filedate, "mmddyy")
OutputFileName = "Reports" & fnamedate & ".zip"
fdir = "some\dir\"

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

This way, you do not need to reference the library, so it's better for compatibility.
 
Remou, with late binding (ie not having any reference to outlook) you have to replace all olXxxx constants by their values.
 
Remou, the late binding did help. I also had to replace .Attach with .Attachments.Add (FilePath\Filename).

PH - What are the constants you refer to in your post? I would like to become more well versed on declaring/using different reference libraries.

Thanks a lot,

Alex

It's a magical time of year in Philadelphia. Eagles training camp marks the end of another brutal season of complaining about the Phillies.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top