Where I coulf find MSMapi32.ocx?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hola

I changed recently to Access 2007 and the above reference do not come with
the program. I got one copy (ver.6.0.8169 dated 18jun'98) from a friend but
after instalation as reference do not work.
Where should I find the correct one?
 
Hola
I want to automate this action, once I produce a report, I pass it to pdf
and send it by email, without leaving the application. Now, I have the
problem in Access.
Or you mean that I could have another way to do it with Outlook?
 
Hi,

In the code window add Outlook to you project via tools where you would have
added MSMapi32.ocx

Then add this function into a module and set the right values:

Public Function SendEmail(ByVal lsRecipients As String, ByVal lsCCs As
String, ByVal lsBCCs As String, _
ByVal lsSubject As String, ByVal lsBodyMessage As
String, ByVal lsAttachments As String) As Long

Dim objOutlook As Outlook.Application
Dim objOlns As Outlook.NameSpace
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

Dim lsEmailAddress As String
Dim lsFile As String

SendEmail = False

On Error GoTo Email_Err
If gbDev = True Then
On Error GoTo 0
End If


Set objOutlook = CreateObject("Outlook.Application")
Set objOlns = objOutlook.GetNamespace("MAPI")

Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
Do While Len(lsRecipients) > 0
'ExtractString strips off each string from the next based on comma
delimitation
'Sorry you'll have to do that bit yourself!
lsEmailAddress = ExtractString(lsRecipients)
If Len(lsEmailAddress) > 0 Then
Set objOutlookRecip = objOutlookMsg.Recipients.Add(lsEmailAddress)
objOutlookRecip.type = olTo
End If
Loop

Do While Len(lsCCs) > 0
lsEmailAddress = ExtractString(lsCCs)
If Len(lsEmailAddress) > 0 Then
Set objOutlookRecip = objOutlookMsg.Recipients.Add(lsEmailAddress)
objOutlookRecip.type = olCC
End If
Loop

Do While Len(lsBCCs) > 0
lsEmailAddress = ExtractString(lsBCCs)
If Len(lsEmailAddress) > 0 Then
Set objOutlookRecip = objOutlookMsg.Recipients.Add(lsEmailAddress)
objOutlookRecip.type = olBCC
End If
Loop


objOutlookMsg.Subject = lsSubject

objOutlookMsg.Body = lsBodyMessage


Do While Len(lsAttachments) > 0
lsFile = ExtractString(lsAttachments)
objOutlookMsg.Attachments.Add (lsFile)
Loop

objOutlookMsg.Send
SendEmail = True
Email_Exit:
Exit Function

Email_Err:
MsgBox "Error while preparing email" & vbCrLf & Err.Description
SendEmail = Err.Number
Resume Email_Exit

End Function


In your form load or project load you may need to add a variation on:

lsProg = Chr$(34) & "C:\Program Files\Microsoft
Outlook\OFFICE11\OUTLOOK.EXE" & Chr$(34) & " /recycle"
Shell lsProg, vbMinimizedNoFocus

Depends on where outlook.exe is.
Note the recycle, or you will end up with multiple outlook sessions
 
Hola

Huuummm, it look very profesional!
I am not an expert at all, but I will try to understand it and use it.
Thanks.
 
PatoPaco said:
Or you mean that I could have another way to do it with Outlook?

In addition to Tim's code there are similar approaches and non Outlook
means at the Microsoft Access Email FAQ
http://www.granite.ab.ca/access/email.htm.

Also consider using Late Binding once you have the Outlook code
working. Thus your app will work even on systems with different
versions of Outlook or without Outlook even installed.

Late binding means you can safely remove the reference and only have
an error when the app executes lines of code in question. Rather than
erroring out while starting up the app and not allowing the users in
the app at all. Or when hitting a mid, left or trim function call.

You'll want to install the reference if you are programming or
debugging and want to use the object intellisense while in the VBA
editor. Then,. once your app is running smoothly, remove the
reference and setup the late binding statements.

Sample code:
' Declare an object variable to hold the object
' reference. Dim as Object causes late binding.
Dim objWordDoc As Object
Set objWordDoc = CreateObject(" Word.Document")

For more information including additional text and some detailed links
see the "Late Binding in Microsoft Access" page at
http://www.granite.ab.ca/access/latebinding.htm
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Back
Top