HTH
Pieter
"Ron Hinds" <bi...@microsoft.com> wrote in message
news:OPc8kTm6...@TK2MSFTNGP02.phx.gbl...
I believe SendObject will always use your default mail client. The
problem is that Outlook likes to make itself the default mail client
when you run it. I don't think it'll do that without requesting some
sort of confirmation, but I wouldn't count on it.
It is possible to use MAPI to explictly send mail using Outlook Express.
For example, the following module provides a function very similar to
SendObject, except that it doesn't have the built-in feature to attach
an Access object.
'----- start of module code -----
Option Compare Database
Option Explicit
' Code adapted from a number of sources, especially
' including Lyle Fairfield, and modified by Dirk Goldgar.
Private Type MapiRecip
Reserved As Long
RecipClass As Long
Name As String
Address As String
EIDSize As Long
EntryID As Long
End Type
Private Type MAPIFileDesc
Reserved As Long
flags As Long
Position As Long
PathName As String
FileName As String
FileType As Long
End Type
Private Type MAPIMessage
Reserved As Long
Subject As String
NoteText As String
MessageType As String
DateReceived As String
ConversationID As String
Originator As Long
flags As Long
RecipCount As Long
Recipients As Long
FileCount As Long
Files As Long
End Type
Private Declare Function MAPISendMail _
Lib "c:\program files\outlook express\msoe.dll" ( _
ByVal Session As Long, _
ByVal UIParam As Long, _
Message As MAPIMessage, _
ByVal flags As Long, _
ByVal Reserved As Long) As Long
Public Function SendMailWithOE( _
ByVal pstrSubject As String, _
ByVal pstrMessage As String, _
Optional ByRef pstrRecipientsTo As String, _
Optional ByRef pstrRecipientsCC As String, _
Optional ByRef pstrRecipientsBCC As String, _
Optional ByVal pstrFiles As String, _
Optional ByVal pblnDisplayMessage As Boolean = True) _
As Long
On Error GoTo Err_Handler
Dim aFiles() As String
Dim aRecips() As String
Dim FilePaths() As MAPIFileDesc
Dim Recips() As MapiRecip
Dim Message As MAPIMessage
Dim lngFlags As Long
Dim lngRC As Long
Dim z As Long
Dim iLastRecip As Integer
If pstrFiles <> vbNullString Then
aFiles = Split(pstrFiles, ",")
ReDim FilePaths(LBound(aFiles) To UBound(aFiles))
For z = LBound(aFiles) To UBound(aFiles)
With FilePaths(z)
.Position = -1
.PathName = StrConv(aFiles(z), vbFromUnicode)
End With
Next z
Message.FileCount = UBound(FilePaths) - LBound(FilePaths) + 1
Message.Files = VarPtr(FilePaths(LBound(FilePaths)))
Else
Message.FileCount = 0
End If
iLastRecip = -1
If Len(pstrRecipientsTo) > 0 Then
Erase aRecips
aRecips = Split(pstrRecipientsTo, ",")
ReDim Preserve Recips(0 To (iLastRecip + 1 + UBound(aRecips)))
For z = LBound(aRecips) To UBound(aRecips)
iLastRecip = iLastRecip + 1
With Recips(iLastRecip)
.RecipClass = 1
If InStr(aRecips(z), "@") <> 0 Then
.Address = StrConv(aRecips(z), vbFromUnicode)
Else
.Name = StrConv(aRecips(z), vbFromUnicode)
End If
End With
Next z
End If
If Len(pstrRecipientsCC) > 0 Then
Erase aRecips
aRecips = Split(pstrRecipientsCC, ",")
ReDim Preserve Recips(0 To (iLastRecip + 1 + UBound(aRecips)))
For z = LBound(aRecips) To UBound(aRecips)
iLastRecip = iLastRecip + 1
With Recips(iLastRecip)
.RecipClass = 2
If InStr(aRecips(z), "@") <> 0 Then
.Address = StrConv(aRecips(z), vbFromUnicode)
Else
.Name = StrConv(aRecips(z), vbFromUnicode)
End If
End With
Next z
End If
If Len(pstrRecipientsBCC) > 0 Then
Erase aRecips
aRecips = Split(pstrRecipientsBCC, ",")
ReDim Preserve Recips(0 To (iLastRecip + 1 + UBound(aRecips)))
For z = LBound(aRecips) To UBound(aRecips)
iLastRecip = iLastRecip + 1
With Recips(iLastRecip)
.RecipClass = 2
If InStr(aRecips(z), "@") <> 0 Then
.Address = StrConv(aRecips(z), vbFromUnicode)
Else
.Name = StrConv(aRecips(z), vbFromUnicode)
End If
End With
Next z
End If
With Message
.NoteText = pstrMessage
.RecipCount = UBound(Recips) - LBound(Recips) + 1
.Recipients = VarPtr(Recips(LBound(Recips)))
.Subject = pstrSubject
End With
If pblnDisplayMessage = True Then
lngFlags = MAPI_DIALOG
Else
lngFlags = 0
End If
SendMailWithOE = MAPISendMail(0, 0, Message, lngFlags, 0)
Exit_Point:
Exit Function
Err_Handler:
subDisplayAndLogError "SendMailWithOE", Err.Number, Err.Description
Resume Exit_Point
End Function
'----- end of module code -----
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)
Thanks!
"Dirk Goldgar" <d...@NOdataSPAMgnostics.com> wrote in message
news:ujyk1im6...@TK2MSFTNGP03.phx.gbl...
Yes, that's right. As posted, it defaults to True, which means that the
message is displayed for the user to edit, after which the user can send
or cancel it.