Fred Hooper
fahooper at trapo.com
Sun Aug 5 07:35:58 CDT 2007
I've used the code below in many places.
Fred
Public Sub SendEmail(strFrom As String, strTo As String, strSubject As
String, strMessage As String)
Dim objEmail As Object
Dim objMsg As Object
Dim objConf As Object
Dim Flds As Variant
Set objMsg = CreateObject("cdo.message")
Set objConf = CreateObject("cdo.configuration")
Set Flds = objConf.Fields
With Flds
' The first item with value "2" indicates that smpt is not installed
on this machine
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") =
2
' Next item is the name of the smpt server to use.
' Look in Outlook | Tools | Email Accounts | View or change... |
Change to find
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
"yourmailhost.com"
' This is the port the smpt server uses, 25 is the default
.Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 25
.Update
End With
With objMsg
Set .configuration = objConf
.To = strTo
.from = strFrom
.Subject = strSubject
.Textbody = strMessage
' It doesn't work with more than one attachment
' .AddAttachment "c:\readme.txt"
.Fields.Update
.Send
End With
Set objMsg = Nothing
Set objConf = Nothing
End Sub
-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Rocky Smolin at
Beach Access Software
Sent: Saturday, August 04, 2007 9:10 PM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Need SMTP Code
Dear List:
I have a lot of Access sites bookmarked but can never find what I need in
them. I'm looking for some code to handle email from Access using SMTP.
Does anyone know if there's a module I can crib from one of the many Access
sites?
MTIA
Rocky
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com