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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change coding to Older Version of MS Office

Status
Not open for further replies.

FeS2

Technical User
Aug 16, 2002
82
US
I have spent the last week working on coding a way to send an e-mail from Access with MS Outlook. I finally got it all figured out and have it running perfect for Outlook 2003. Turns out, the 3 people that will be using the database are running Office 2000 and my code doesn't work on their machines. Any advice on fixing this, here is the code I am using. I was thinking I might have to sit at one of their desks and redo all the programming, and testing.

Private Sub cmdE_mail_Click()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim rsConnect As ADODB.Connection
Dim rs As ADODB.Recordset
Dim strBody As String
Dim strSQL As String
Dim strSubject As String

Set rsConnect = CurrentProject.Connection
DoCmd.SetWarnings False

'sets the body of the e-mail
Set rs = New ADODB.Recordset
strSQL = "SELECT [phone], [acs type], [order id], [cable pair], [prov type] FROM [Faxination1];"
rs.Open strSQL, rsConnect, adOpenDynamic, adLockOptimistic
rs.MoveFirst
strBody = rs.GetString(adClipString)

'Sets the e-mail subject line
[wire center].SetFocus
strSubject = "Comp" & " " & [wire center].Text & " "
[fax time].SetFocus
strSubject = strSubject & [fax time].Text

'Opens Outlook and creates a new E-mail
Set objOutlook = CreateObject("outlook.application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
Set objOutlookRecip = .Recipients.Add("Local Prov")
objOutlookRecip.Type = olTo
.Subject = strSubject
.Body = strBody
.Importance = olImportanceNormal
'Use .send to send the message right away
'Use .display to edit the message before sending it
.Display
End With

Set objOutlook = Nothing
Set objOutlookMsg = Nothing
Set objOutlookRecip = Nothing
Set rs = Nothing
End Sub
 
my code doesn't work
Any error message ? Which line is highlighted when in debug mode ?
Anyway I suggest you check the references:
when in VBE (Alt+F11) menu Tools -> References ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV, you were right, I had the ver 11 Outlook ref file loaded and for the older systems it needed ver 9. I corrected this but when I opened the form and used it, it must have automatically changed the ref file back to 11 becuase when the people with the older systems tried using the form this morning it gave the same problem. Any idea on why Access would change the reference file?
 
When opening an app with references to other Office application from a "lower" version, this might often happen, whilst if you compile it in the lowest version and distribute, most often there's no hassle.

What I tend to do, is using late binding for automation.

[tt]Dim objOutlook As object ' Outlook.Application
Dim objOutlookMsg As object ' Outlook.MailItem
Dim objOutlookRecip As object ' Outlook.Recipient[/tt]

Then you'd also have to find the litteral value of the constants, cause when you remove the reference to Outlook, those wont be known. In my code, it would probably look something like this:

[tt]Set objOutlookMsg = objOutlook.CreateItem(0) ' olMailItem[/tt]

The other two, olTo, and olImportanceNormal, I think both are 1.

Roy-Vidar
 
I was just able to find a downloadable file from Microsoft that has all the programming refences including all the Outlook Constants. Thanks for your help, i'll let you know how it goes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top