I have used the below method brought to my
attention by Tom back in August and it works great. To send to multiple
recipients, just past strTo a string with multiple addresses separated by
semicolons.
HTH,
Toby
****************Archived
Email************************************
----- Original Message -----
From: Tom Oakes
Sent: Tuesday, August 09, 2005 10:05 AM
Subject: RE: [AccessDevelopers] E-mail with spreadsheet
attachment I have a client that doesn't have Outlook accounts
available on the application server, so we resorted to using the CDO library to
send email. You can essentially do everything you can with Outlook -
except edit the email prior to sending. The CDO library does not raise any
type of security warning.
My routine looks like this:
(the bolded parts are system option functions - you can
replace these with literal strings)
'***** code start *****'
Public Function SendCDOMail(strTo As String, strSubject As
String, strBody As String, strAttach As String, blnHTML As Boolean) As
Boolean
On Error GoTo Failure Dim objMessage As
CDO.Message Dim objConfig As CDO.Configuration Dim objFields As Variant Const cboSendUsingPort As Integer = 2 Set objConfig = New CDO.Configuration Set objMessage = New CDO.Message Set objFields = objConfig.Fields With objFields .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = GetSMTPServer() '<-- valid SMTP server .Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 .Update End With With objMessage Set .Configuration = objConfig .TO = strTo .From = GetNTUSER & "@" & GetMailDomain() '<-- automatically uses current user as "From" .Subject = strSubject If blnHTML = True Then .HTMLBody = strBody Else .TextBody = strBody End If If strAttach <> "" Then .AddAttachment (strAttach) .Send End With Set objMessage = Nothing Set objFields = Nothing Set objConfig = Nothing SendCDOMail = True EXITROUTINE: Exit Function Failure: SendCDOMail = False MsgBox Err & " " & Err.Description Resume EXITROUTINE End Function '***** code end *****' **************End Archived
Email**************************************
|
- [AccessDevelopers] Sending Email via Code Lonnie Johnson
- Re: [AccessDevelopers] Sending Email via Code Toby Bierly
- Re: [AccessDevelopers] Sending Email via Code Lonnie Johnson