Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / August 2006

Tip: Looking for answers? Try searching our database.

Sending an attachment to Outlook Express from ACCESS

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David - 28 Aug 2006 20:13 GMT
Hi - I'm trying to attach a comma-delimited output file created from ACCESS
to an email message to send to a supplier.  Someone at the ACCESS newsgroup
suggested the following code:

Public Sub SendMailCDO(ToWHom As String, FromWhom As String, Subject As
String, Body As String, Optional AttachmentPath As String)

Const cdoDefaults = -1
Const cdoIIS = 1
Const cdoOutlookExpress = 2

Dim Message As Object 'CDO.Message

Set Message = CreateObject("CDO.Message")

With Message
   'Use dafault config from system
   .Configuration.Load -1
   
   .To = ToWHom
   If Len(FromWhom) > 0 Then
       .From = FromWhom
   End If
   
   .Subject = Subject
   
   .TextBody = Body
   
   If Len(AttachmentPath) > 0 Then
       .AddAttachment AttachmentPath
   End If
   
   .Send
   
End With

End Sub

I get a runtime error (at the .Send, I imagine) which says that the message
could not be sent to the server.  

Can you shed any light on this?  A couple of possibilites that have occurred
to me are:

(1) Only works with Outlook, not OE - I'll use Outlook if that'll fix it
(2) How does the routine know I want to send to OE anyway?
(3) Does the CDO library support this functionality from XP?

Thanks,
dave
Signature

Dave
PHONE SOURCE
www.thephonesource.com

Eric Legault [MVP - Outlook] - 31 Aug 2006 17:17 GMT
Unless this e-mail needs to be sent from a web server, you're using the wrong
programming library.  CDOSYS (which is what you're using) is much different
from CDO 1.21, which is an alternative programming library compared to using
the Outlook Object Model with VBA (or any COM aware development language).

If you need to send e-mail with any mail client, you need to use the Simple
MAPI library:

Programming with Simple MAPI:
http://msdn.microsoft.com/library/en-us/mapi/html/f12359b4-d525-4921-9ef8-e638e4
c4fef7.asp?frame=true


But you should really take a look at Access' SendObject method, which allows
you to e-mail Access objects easily.  It should do everything you need.

Signature

Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/

> Hi - I'm trying to attach a comma-delimited output file created from ACCESS
> to an email message to send to a supplier.  Someone at the ACCESS newsgroup
[quoted text clipped - 46 lines]
> Thanks,
> dave
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.