email through SMTP server

I

Ian

Could have sworn I've read this before, but cant seem to find it now. I am
trying to send an email from a machine that will not have outlook. all I'm
doing is sending a 1 line text email and have an SMPT server to do it through.

Anyone remember how to do this without the docmd.sendobject?

Thanks,
Ian
 
A

AlexM

On Error GoTo SendError

Dim rs As DAO.Recordset
Set rs = CurrentDb().OpenRecordset(INSERT YOUR CODE)

Dim objMessage As Object
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = strSubject & " " & Date
objMessage.From = rs.Fields("EmailAddress")
objMessage.To = strRecipient
objMessage.TextBody = strBody

If Len(strAttachment) >= 1 Then
objMessage.AddAttachment strAttachment
End If

'Type of authentication, NONE, Basic (Base64 encoded), NTLM
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1

'Your UserID on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusername") =
rs.Fields("Username")

'Your password on the SMTP server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendpassword") =
rs.Fields("Password")

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") =
rs.Fields("Server")
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update
objMessage.Send

Set objMessage = Nothing
rs.Close
Set rs = Nothing

Exit Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top