Carolyn Johnson
cjlabs at worldnet.att.net
Sat Aug 1 07:05:42 CDT 2009
Thanks -- I'll give it a try.
Carolyn
----- Original Message -----
From: Max Wanadoo
To: 'Access Developers discussion and problem solving'
Sent: Saturday, August 01, 2009 5:15 AM
Subject: Re: [AccessD] Create email in Access via Thunderbird
Hi Carolyn,
You could try CDO. Here is an example (not tested, just extracted and
stripped from code that does work)
Max
Option Compare Database
Option Explicit
Private Sub sSendMailByCDOExample()
On Error GoTo errhandler
Dim objMessage
Dim strErr As String
Const conErr1 As String = "The server rejected one or more recipient
addresses. The server response was: 550 "
Const conErr2 As String = "The server rejected one or more recipient
addresses. The server response was: 501 bad address syntax: <"
Const ConErrX As String = "The transport failed to connect to the server"
Set objMessage = CreateObject("CDO.Message") ' Create the message
object.
objMessage.From = "You Are Supported<Support at mydomain.com>"
objMessage.To = "joe.bloggs at botmail.com"
objMessage.Subject = "My Subject"
objMessage.TextBody = "This is some sample message text.." & vbCrLf &
"It was sent using SMTP authentication."
' objMessage.HTMLBody = strHTML' Or you could use HTML as:
' ATTACHMENT : Add an attachment Can be any valid url
objMessage.AddAttachment "C:\MyAttachment"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/confi
guration/sendusing") = 2
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/confi
guration/smtpserver") = "smtp.mydomain.com"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/confi
guration/smtpauthenticate") = 1
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/confi
guration/sendusername") = "Support at MyDomain.com"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/confi
guration/sendpassword") = "secret"
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/confi
guration/smtpserverport") = 587 ' or try 465 or 25
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/confi
guration/smtpusessl") = False
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/confi
guration/smtpconnectiontimeout") = 60
objMessage.Configuration.Fields.Update ' Update configuration
MsgBox objMessage.GetStream.ReadText ' Use to show the message.
objMessage.Send ' Send the message.
exithere:
Exit Sub
errhandler:
strErr = Err.Description
'debug.print strErr
If InStr(strErr, ConErrX) > 0 Then
MsgBox ConErrX & " Program Aborted"
Stop
End If
If InStr(strErr, conErr1) > 0 Then
If InStr(strErr, "no such domain") > 0 Then
MsgBox "Bad Domain"
End If
End If
GoTo exithere
End Sub
--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com