Email Attachments w/ Outlook Express

  • Thread starter Thread starter kdetrano
  • Start date Start date
K

kdetrano

Guest
I need to send emails with multiple reciepents from MS-Access using Outlook Express, and I need to include an attachment which is a file not native to Access (i.e. an external .pdf file). Does anyone have the code for this that they can share with me? I've found various examples for Outlook, but I need the email to be sent automatically, without waiting for users to respond to the security message.

Thank you!!!
 
You will have to use a reference to Outlook Express - I've only done Outlook before, so I can't help you too much there. Add it to your references then explore it in your object browser.

The DoCmd.SendObject command won't do you any good - it only works for acSendObjectTypes:

acSendDataAccessPage
acSendForm
acSendModule
acSendNoObject default
acSendQuery
acSendReport
acSendTable
 
Try this. It works for me. :)
Sub sendmailCDO(eaddress As String, ecc As String, ebcc As String, efrom As String, esubj As String, ebody As String,

eattachment As String)


' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Windows 2000 Library
Dim iConf As New CDO.Configuration
Dim Flds As ADODB.Fields

Set Flds = iConf.Fields
Flds(cdoSendUsingMethod) = cdoSendUsingPort ' 2
Flds(cdoSMTPServer) = "smtp.server.com"
Flds(cdoSMTPServerPort) = 25
'Flds(cdoSMTPAccountName) = "My Name"
'Flds(cdoSMTPAuthenticate) = cdoBasic ' 1

' IMPORTANT: Storing user names and passwords inside source code
' can lead to security vulnerabilities in your software. Do not
' store user names and passwords in your production code.
'Flds(cdoSendUserName) = "domain\username"
'Flds(cdoSendPassword) = "password"

'Flds(cdoSendEmailAddress) = """MySelf"" <example@example.com>"
'Flds(cdoSMTPUseSSL) = True
Flds.Update

Dim iMsg As New CDO.Message
Set iMsg.Configuration = iConf
' ... compose message; add attachments, etc
With iMsg
Set .Configuration = iConf
.To = eaddress
.CC = ecc
.BCC = ebcc
.from = efrom '"""MySelf"" <example@example.com>"
.Subject = esubj '"Test"
.TextBody = ebody ' "Body text"
.AddAttachment eattachment ' "D:\temp\text.txt"
' You can add any file you want with this line .AddAttachment "C:/Test.txt"
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing


End Sub
 
The transport failed to connect to the server

THANK you!! Unfortunately, I'm getting the error "The transport failed to connect to the server" when I run this. I've checked to be sure that my mail server is using port 25. Any ideas?
 
hello,

i've tried this code too and have also the same error..

any suggestions??
 

Users who are viewing this thread

Back
Top Bottom