PDA

Click to See Complete Forum and Search --> : MSMapi32 Help


Bjamin0325
Feb 3rd, 2001, 10:44 AM
How does the MSMapi32 api work? Is it possible to use it to send email without the user seeing? I don't have this on my machine, can I get it? How? Please I need help I don't know what I'm doing but I need to figure this out.

JordanChris
Feb 6th, 2001, 09:39 AM
Typically, in almost anything you do, you will NOT want to use the MAPI interfaces directly.

They are complex, designed for use from C, and require lots of understanding about Outlook and what Exchange is trying to do.

Alternatives:
Take a look at Chapter 5 of the MS Office 2000 - Visual Basic Programmers Guide (available on Technet and other places). This describes use of Outlook from OLE Automation point of view.

E.G:

Function CreateMail(astrRecip As Variant, _
strSubject As String, _
strMessage As String, _
Optional astrAttachments As Variant) As Boolean
' This procedure illustrates how to create a new mail message
' and use the information passed as arguments to set message
' properties for the subject, text (Body property), attachments,
' and recipients.

Dim objNewMail As Outlook.MailItem
Dim varRecip As Variant
Dim varAttach As Variant
Dim blnResolveSuccess As Boolean

On Error GoTo CreateMail_Err

' Use the InitializeOutlook procedure to initialize global
' Application and NameSpace object variables, if necessary.
If golApp Is Nothing Then
If InitializeOutlook = False Then
MsgBox "Unable to initialize Outlook Application " _
& "or NameSpace object variables!"
Exit Function
End If
End If

Set golApp = New Outlook.Application
Set objNewMail = golApp.CreateItem(olMailItem)
With objNewMail
For Each varRecip In astrRecip
.Recipients.Add varRecip
Next varRecip
blnResolveSuccess = .Recipients.ResolveAll
For Each varAttach In astrAttachments
.Attachments.Add varAttach
Next varAttach
.Subject = strSubject
.Body = strMessage
If blnResolveSuccess Then
.Send
Else
MsgBox "Unable to resolve all recipients. Please check " _
& "the names."
.Display
End If
End With

CreateMail = True

CreateMail_End:
Exit Function
CreateMail_Err:
CreateMail = False
Resume CreateMail_End
End Function

Bjamin0325
Feb 6th, 2001, 02:58 PM
Thanks a bunch for the help.