By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,663 Members | 2,157 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,663 IT Pros & Developers. It's quick & easy.

Emailing a file using access

P: n/a
Hello,
I am using access 2000 and I am trying to email a csv file. I have
only used the docmd.sendobject command but you can only email objects
that are within the access database ( as far as I can tell anyway). I
need to email a file that is not in my database. Is there another way
I can send an email without using sendobject that would allow me to do
this. Thanks for any help.

Regards,
Bill Mahoney
Nov 12 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
bill mahoney wrote:
Hello,
I am using access 2000 and I am trying to email a csv file. I have
only used the docmd.sendobject command but you can only email objects
that are within the access database ( as far as I can tell anyway). I
need to email a file that is not in my database. Is there another way
I can send an email without using sendobject that would allow me to do
this. Thanks for any help.

Regards,
Bill Mahoney


One way is to reference the Outlook object (assuming that is what you
are using:) and send the email using code (which also allows
attachments)... do a web search for examples.
--
regards,

Bradley
Nov 12 '05 #2

P: n/a
Pat
If you're on an NT-based machine (NT, 2K, XP) it doesn't get any easier
than using CDONTS. The machine must be running the SMTP service and have
access to the internet. You will also need to add a reference to the CDO
library within Access. After this, it's as simple as:

Dim oEMail As New CDONTS.EMail

oEMail.From "an*****@anydomain.com"
oEMail.To "yo*******@yourdomain.com"
oEMail.BodyFormat = CdoBodyFormatText
oEMail.Body = "Insert some useful text here"
oEMail.Importance = CdoHigh
oEMail.AttachFile "C:\filename.txt"
oEMail.Send

Or, if you access to an SMTP server, you might try this CDO routine. You
will still need a reference to the CDO library.

Sub SendEmail()
Const MailSender as String = "sender @ yourdomain.com"
Const MailRecipient as String = "recipient @ anotherdomain.com"
Const MailCCRecipient as String = "cc @ anotherdomain.com"
Const MailSubject as String = "Here's an email with an attachment"
Const MailBody as Strnig = "See the attachment"

Dim iMsg as New CDO.Message
Dim iConf as New CDO.Configuration
Dim Flds as New CDO.Fields
Dim strAttachment as String

strAttachment = "C:\somefile.txt"

With Flds
.Item(cdoSMTPServer) = "ip address or name of smtp server"
.Item(cdoSMTPServerPort) = 25 ' typically
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPConnectionTimeout) = 200
.Item(cdoSMTPAuthenticate) = cdoNTLM
End With

With iMsg
Set .Configuration = iConf
.To = MailRecipient
.CC = MailCCRecipient
.From = MailSender
.Subject = MailSubject
.TextBody = MailBody
.AddAttachment (strAttachment)
.MDNRequested = True 'return receipt on
.Send
End With

End Sub
For a great overview of the many options for email with Access check out
Tony Toews'
website:
http://www.granite.ab.ca/access/email.htm

HTH
Pat
"bill mahoney" <bi***@alcottgroup.com> wrote in message
news:fa**************************@posting.google.c om...
Hello,
I am using access 2000 and I am trying to email a csv file. I have
only used the docmd.sendobject command but you can only email objects
that are within the access database ( as far as I can tell anyway). I
need to email a file that is not in my database. Is there another way
I can send an email without using sendobject that would allow me to do
this. Thanks for any help.

Regards,
Bill Mahoney

Nov 12 '05 #3

P: n/a
"Pat" <no*****@ihatespam.bum> wrote in message news:<Sl********************@fe2.texas.rr.com>...
If you're on an NT-based machine (NT, 2K, XP) it doesn't get any easier
than using CDONTS. The machine must be running the SMTP service and have
access to the internet. You will also need to add a reference to the CDO
library within Access. After this, it's as simple as:

Dim oEMail As New CDONTS.EMail

oEMail.From "an*****@anydomain.com"
oEMail.To "yo*******@yourdomain.com"
oEMail.BodyFormat = CdoBodyFormatText
oEMail.Body = "Insert some useful text here"
oEMail.Importance = CdoHigh
oEMail.AttachFile "C:\filename.txt"
oEMail.Send

Or, if you access to an SMTP server, you might try this CDO routine. You
will still need a reference to the CDO library.

Sub SendEmail()
Const MailSender as String = "sender @ yourdomain.com"
Const MailRecipient as String = "recipient @ anotherdomain.com"
Const MailCCRecipient as String = "cc @ anotherdomain.com"
Const MailSubject as String = "Here's an email with an attachment"
Const MailBody as Strnig = "See the attachment"

Dim iMsg as New CDO.Message
Dim iConf as New CDO.Configuration
Dim Flds as New CDO.Fields
Dim strAttachment as String

strAttachment = "C:\somefile.txt"

With Flds
.Item(cdoSMTPServer) = "ip address or name of smtp server"
.Item(cdoSMTPServerPort) = 25 ' typically
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPConnectionTimeout) = 200
.Item(cdoSMTPAuthenticate) = cdoNTLM
End With

With iMsg
Set .Configuration = iConf
.To = MailRecipient
.CC = MailCCRecipient
.From = MailSender
.Subject = MailSubject
.TextBody = MailBody
.AddAttachment (strAttachment)
.MDNRequested = True 'return receipt on
.Send
End With

End Sub
For a great overview of the many options for email with Access check out
Tony Toews'
website:
http://www.granite.ab.ca/access/email.htm

HTH
Pat
Thanks for the help Pat, it worked great.

Regards,
Bill

"bill mahoney" <bi***@alcottgroup.com> wrote in message
news:fa**************************@posting.google.c om...
Hello,
I am using access 2000 and I am trying to email a csv file. I have
only used the docmd.sendobject command but you can only email objects
that are within the access database ( as far as I can tell anyway). I
need to email a file that is not in my database. Is there another way
I can send an email without using sendobject that would allow me to do
this. Thanks for any help.

Regards,
Bill Mahoney

Nov 12 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.