A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Tags: , , , ,

Sending an attachment to Outlook Express from ACCESS





 
 
Thread Tools Display Modes
  #1  
Old August 28th 06, 09:13 PM posted to microsoft.public.outlook.program_vba
David
external usenet poster
 
Posts: 170
Default Sending an attachment to Outlook Express from ACCESS

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 a

(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
--
Dave
PHONE SOURCE
www.thephonesource.com
Ads
  #2  
Old August 31st 06, 06:17 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 817
Default Sending an attachment to Outlook Express from ACCESS

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...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.

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


"David" wrote:

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 a

(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
--
Dave
PHONE SOURCE
www.thephonesource.com

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does Outlook damage pdf files when sending as attachment? Mukhtar Outlook - Using Forms 1 June 23rd 06 10:49 PM
how do I break up a large attachment that I am sending in Outlook roger Outlook - Installation 1 April 19th 06 09:11 PM
Import attachment from Outlook into Access Ocean Outlook and VBA 1 March 27th 06 09:58 PM
Sending Email With Outlook Or Even Web Access yossi.brown@gmail.com Outlook - General Queries 1 March 22nd 06 05:11 PM
Outlook not displaying attachment from Access via code vavroom@gmail.com Outlook - General Queries 4 February 28th 06 12:30 AM


All times are GMT +1. The time now is 02:50 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2008 Outlook Banter, part of the NewsgroupBanter project.
The comments are property of their posters.
Credit Card - Adverse Credit Remortgage - Personal Loans - Loans - Mortgage Calculator