dbTalk Databases Forums  

Email attachment with CDO

comp.databases.ms-access comp.databases.ms-access


Discuss Email attachment with CDO in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Aaron Kempf
 
Posts: n/a

Default Re: Email attachment with CDO - 11-09-2011 , 01:17 PM






I just do this via SQL Server and XP_SENDMAIL or the SQL 2005 replacement

I'd just rather setup email on ONE machine than on TEN machines.

Reply With Quote
  #12  
Old   
Lou O
 
Posts: n/a

Default Re: Email attachment with CDO - 11-09-2011 , 02:03 PM






On Nov 9, 9:36*am, "Jon Lewis" <jon.le... (AT) cutthespambtinternet (DOT) com>
wrote:
Quote:
I tried this and had no error on the CreateObject line. *The only CDO
reference I have is to cdosys.dll. *That said I do get an error on the
objMessage.Send line as you have to configure the SMTP server details before
you can send using CDO. *The following seems a good tutorial on the subject
in a VB/VBA environment:

http://www.developerfusion.com/artic...mail-dispatch/

HTH

Jon

"Lou O" <lgeastw... (AT) gmail (DOT) com> wrote in message

news:3a330240-4ef6-432e-82b8-b2ac3fedaa97 (AT) d5g2000yqg (DOT) googlegroups.com...
Douglas, I removed the "New" keyword but the error persists.
Regarding the missing module referred in the error - do you know what
that is?
Is it a library or something else?
I have downloaded and installed MS Collaboration Data Objects 1.2.1 as
well as Microsoft Exchange Server MAPI Client.
both CDO.dll & CDOsys.dll appear in my System32 folder.
I have checked off CDO Library 1.21 and CDO for Windows 2000 Library
in the references.
The code compiles without errors - but the error still pops up on the
Set .....CreateObject
I must be overlooking or missing something else but I'm not sure what.
Do you have any further ideas? Thanks

On Nov 7, 6:15 pm, "Douglas J Steele"







NOSPAM_djsteele (AT) NOSPAM_gmail (DOT) com> wrote:
Not sure whether it's related to your error, but you do not use the New
keyword in conjunction with Set. Try:

Dim objMessage As CDO.Message

Set objMessage = CreateObject("CDO.Message")

"Lou O" wrote in message

news:f3919cc9-5317-4703-b6cd-a6af6def7666 (AT) w20g2000prc (DOT) googlegroups.com....

I have been looking for a way to send an email from access with an
independent file attachment. In other words without using the
sendobject method which sends only access objects.
In this news group I came across the CDO Library method with very
simple code as below

Dim objMessage As New CDO.Message
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "m... (AT) my (DOT) com"
objMessage.To = "loosterh... (AT) gmail (DOT) com"
objMessage.TextBody = "This is some sample message text."
objMessage.AddAttachment "c:\temp\readme.txt"

However the code generates the following error running the
Set......CreateObject line

Run-time error '-2147024770(8007007e)':
Automation Error
The specified module could not be found.

Does anyone know what this error means?
Am I missing a class module that this method requires?
I have a suspicion that it refers to MS Outlook (not installed) but
I'm not sure.

Thanks for your help
Lou O
Thanks Jon
I followed the link and followed the tutorial.
But alas the same error pops up.
I know it's something stupid and obvious but it continues to elude me!
Would you mind posting your code behind this procedure to see if can
spot the obvious?
Lou

Reply With Quote
  #13  
Old   
Jon Lewis
 
Posts: n/a

Default Re: Email attachment with CDO - 11-10-2011 , 05:37 AM



I'm using your code Lou and for me there is no problem with the Set
objMessage = CreateObject("CDO.Message") line. Like I say the only problem
with your code for me is that you haven't set the SMTP properties required
so the following works perfectly for me.

Dim objMessage As New CDO.Message
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "jo.send (AT) whatever (DOT) com"
objMessage.To = "jo.receive (AT) any (DOT) com"
objMessage.TextBody = "This is some sample message text."
objMessage.AddAttachment "c:\temp\sample.txt"

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2
'Name or IP of remote SMTP server
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
= "dellserver"
'Server port
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25
objMessage.Configuration.Fields.Update
objMessage.Send

Try it in a new database with standard references plus a reference to:
Microsoft CDO for Windows 2000 Library. The location of this on my PC is
C:\Windows\System32\cdosys.dll. Does this reference appear in the available
references list? If not (because as others have pointed out the CDO library
is not necessarily installed as standard) you may need to register
cdosys.dll by running regsvr32 from a command prompt (google to find out
how).

Does this help?

Jon

"Lou O" <lgeastwood (AT) gmail (DOT) com> wrote

On Nov 9, 9:36 am, "Jon Lewis" <jon.le... (AT) cutthespambtinternet (DOT) com>
wrote:
Quote:
I tried this and had no error on the CreateObject line. The only CDO
reference I have is to cdosys.dll. That said I do get an error on the
objMessage.Send line as you have to configure the SMTP server details
before
you can send using CDO. The following seems a good tutorial on the subject
in a VB/VBA environment:

http://www.developerfusion.com/artic...mail-dispatch/

HTH

Jon

"Lou O" <lgeastw... (AT) gmail (DOT) com> wrote in message

news:3a330240-4ef6-432e-82b8-b2ac3fedaa97 (AT) d5g2000yqg (DOT) googlegroups.com...
Douglas, I removed the "New" keyword but the error persists.
Regarding the missing module referred in the error - do you know what
that is?
Is it a library or something else?
I have downloaded and installed MS Collaboration Data Objects 1.2.1 as
well as Microsoft Exchange Server MAPI Client.
both CDO.dll & CDOsys.dll appear in my System32 folder.
I have checked off CDO Library 1.21 and CDO for Windows 2000 Library
in the references.
The code compiles without errors - but the error still pops up on the
Set .....CreateObject
I must be overlooking or missing something else but I'm not sure what.
Do you have any further ideas? Thanks

On Nov 7, 6:15 pm, "Douglas J Steele"







NOSPAM_djsteele (AT) NOSPAM_gmail (DOT) com> wrote:
Not sure whether it's related to your error, but you do not use the New
keyword in conjunction with Set. Try:

Dim objMessage As CDO.Message

Set objMessage = CreateObject("CDO.Message")

"Lou O" wrote in message

news:f3919cc9-5317-4703-b6cd-a6af6def7666 (AT) w20g2000prc (DOT) googlegroups.com...

I have been looking for a way to send an email from access with an
independent file attachment. In other words without using the
sendobject method which sends only access objects.
In this news group I came across the CDO Library method with very
simple code as below

Dim objMessage As New CDO.Message
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "m... (AT) my (DOT) com"
objMessage.To = "loosterh... (AT) gmail (DOT) com"
objMessage.TextBody = "This is some sample message text."
objMessage.AddAttachment "c:\temp\readme.txt"

However the code generates the following error running the
Set......CreateObject line

Run-time error '-2147024770(8007007e)':
Automation Error
The specified module could not be found.

Does anyone know what this error means?
Am I missing a class module that this method requires?
I have a suspicion that it refers to MS Outlook (not installed) but
I'm not sure.

Thanks for your help
Lou O
Thanks Jon
I followed the link and followed the tutorial.
But alas the same error pops up.
I know it's something stupid and obvious but it continues to elude me!
Would you mind posting your code behind this procedure to see if can
spot the obvious?
Lou

Reply With Quote
  #14  
Old   
Lou O
 
Posts: n/a

Default Re: Email attachment with CDO - 11-10-2011 , 11:04 AM



On Nov 10, 6:37*am, "Jon Lewis" <jon.le... (AT) cutthespambtinternet (DOT) com>
wrote:
Quote:
I'm using your code Lou and for me there is no problem with the Set
objMessage = CreateObject("CDO.Message") line. *Like I say the only problem
with your code for me is that you haven't set the SMTP properties required
so the following works perfectly for me.

Dim objMessage As New CDO.Message
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "jo.s... (AT) whatever (DOT) com"
objMessage.To = "jo.rece... (AT) any (DOT) com"
objMessage.TextBody = "This is some sample message text."
objMessage.AddAttachment "c:\temp\sample.txt"

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2
'Name or IP of remote SMTP server
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
= "dellserver"
'Server port
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25
objMessage.Configuration.Fields.Update
objMessage.Send

Try it in a new database with standard references plus a reference to:
Microsoft CDO for Windows 2000 Library. *The location of this on my PC is
C:\Windows\System32\cdosys.dll. *Does this reference appear in the available
references list? *If not (because as others have pointed out the CDO library
is not necessarily installed as standard) you may need to register
cdosys.dll by running regsvr32 from a command prompt (google to find out
how).

Does this help?

Jon
Hi Jon
Thanks for your input.
However it's still not working.
I've done the following steps;
create a new database,
create form with button
button click event code as per your post
Then trying to add cdosys.dll reference (it's in the list) produces
the following message "Name conflicts with existing module, project,
or library"
When the message is dismissed, the reference has not been added!

The standard references are;
Visual Basic For Applications
Microsoft Access 12.0 Object Library
OLE Automation
Microsoft Office 12.0 Access database engine Object Library
Does this look right?
btw I'm using Access 2007

AND I'm stumped.

Any more help would be much appreciated!
Lou
Quote:
"Lou O" <lgeastw... (AT) gmail (DOT) com> wrote in message

news:15ff9e40-a78f-47f3-9678-8e534dcb889a (AT) y7g2000vbe (DOT) googlegroups.com...
On Nov 9, 9:36 am, "Jon Lewis" <jon.le... (AT) cutthespambtinternet (DOT) com
wrote:









I tried this and had no error on the CreateObject line. The only CDO
reference I have is to cdosys.dll. That said I do get an error on the
objMessage.Send line as you have to configure the SMTP server details
before
you can send using CDO. The following seems a good tutorial on the subject
in a VB/VBA environment:

http://www.developerfusion.com/artic...mail-dispatch/

HTH

Jon

"Lou O" <lgeastw... (AT) gmail (DOT) com> wrote in message

news:3a330240-4ef6-432e-82b8-b2ac3fedaa97 (AT) d5g2000yqg (DOT) googlegroups.com...
Douglas, I removed the "New" keyword but the error persists.
Regarding the missing module referred in the error - do you know what
that is?
Is it a library or something else?
I have downloaded and installed MS Collaboration Data Objects 1.2.1 as
well as Microsoft Exchange Server MAPI Client.
both CDO.dll & CDOsys.dll appear in my System32 folder.
I have checked off CDO Library 1.21 and CDO for Windows 2000 Library
in the references.
The code compiles without errors - but the error still pops up on the
Set .....CreateObject
I must be overlooking or missing something else but I'm not sure what.
Do you have any further ideas? Thanks

On Nov 7, 6:15 pm, "Douglas J Steele"

NOSPAM_djsteele (AT) NOSPAM_gmail (DOT) com> wrote:
Not sure whether it's related to your error, but you do not use the New
keyword in conjunction with Set. Try:

Dim objMessage As CDO.Message

Set objMessage = CreateObject("CDO.Message")

"Lou O" wrote in message

news:f3919cc9-5317-4703-b6cd-a6af6def7666 (AT) w20g2000prc (DOT) googlegroups.com....

I have been looking for a way to send an email from access with an
independent file attachment. In other words without using the
sendobject method which sends only access objects.
In this news group I came across the CDO Library method with very
simple code as below

Dim objMessage As New CDO.Message
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "m... (AT) my (DOT) com"
objMessage.To = "loosterh... (AT) gmail (DOT) com"
objMessage.TextBody = "This is some sample message text."
objMessage.AddAttachment "c:\temp\readme.txt"

However the code generates the following error running the
Set......CreateObject line

Run-time error '-2147024770(8007007e)':
Automation Error
The specified module could not be found.

Does anyone know what this error means?
Am I missing a class module that this method requires?
I have a suspicion that it refers to MS Outlook (not installed) but
I'm not sure.

Thanks for your help
Lou O

Thanks Jon
I followed the link and followed the tutorial.
But alas the same error pops up.
I know it's something stupid and obvious but it continues to elude me!
Would you mind posting your code behind this procedure to see if can
spot the obvious?
Lou

Reply With Quote
  #15  
Old   
Jon Lewis
 
Posts: n/a

Default Re: Email attachment with CDO - 11-11-2011 , 07:28 AM



It does appear to be a problem with the CDOSys file/registration/reference.
Maybe do another post with this specific issue to see if someone can help.

Jon
"Lou O" <lgeastwood (AT) gmail (DOT) com> wrote

On Nov 10, 6:37 am, "Jon Lewis" <jon.le... (AT) cutthespambtinternet (DOT) com>
wrote:
Quote:
I'm using your code Lou and for me there is no problem with the Set
objMessage = CreateObject("CDO.Message") line. Like I say the only problem
with your code for me is that you haven't set the SMTP properties required
so the following works perfectly for me.

Dim objMessage As New CDO.Message
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "jo.s... (AT) whatever (DOT) com"
objMessage.To = "jo.rece... (AT) any (DOT) com"
objMessage.TextBody = "This is some sample message text."
objMessage.AddAttachment "c:\temp\sample.txt"

objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2
'Name or IP of remote SMTP server
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")
= "dellserver"
'Server port
objMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")
= 25
objMessage.Configuration.Fields.Update
objMessage.Send

Try it in a new database with standard references plus a reference to:
Microsoft CDO for Windows 2000 Library. The location of this on my PC is
C:\Windows\System32\cdosys.dll. Does this reference appear in the
available
references list? If not (because as others have pointed out the CDO
library
is not necessarily installed as standard) you may need to register
cdosys.dll by running regsvr32 from a command prompt (google to find out
how).

Does this help?

Jon
Hi Jon
Thanks for your input.
However it's still not working.
I've done the following steps;
create a new database,
create form with button
button click event code as per your post
Then trying to add cdosys.dll reference (it's in the list) produces
the following message "Name conflicts with existing module, project,
or library"
When the message is dismissed, the reference has not been added!

The standard references are;
Visual Basic For Applications
Microsoft Access 12.0 Object Library
OLE Automation
Microsoft Office 12.0 Access database engine Object Library
Does this look right?
btw I'm using Access 2007

AND I'm stumped.

Any more help would be much appreciated!
Lou
Quote:
"Lou O" <lgeastw... (AT) gmail (DOT) com> wrote in message

news:15ff9e40-a78f-47f3-9678-8e534dcb889a (AT) y7g2000vbe (DOT) googlegroups.com...
On Nov 9, 9:36 am, "Jon Lewis" <jon.le... (AT) cutthespambtinternet (DOT) com
wrote:









I tried this and had no error on the CreateObject line. The only CDO
reference I have is to cdosys.dll. That said I do get an error on the
objMessage.Send line as you have to configure the SMTP server details
before
you can send using CDO. The following seems a good tutorial on the
subject
in a VB/VBA environment:

http://www.developerfusion.com/artic...mail-dispatch/

HTH

Jon

"Lou O" <lgeastw... (AT) gmail (DOT) com> wrote in message

news:3a330240-4ef6-432e-82b8-b2ac3fedaa97 (AT) d5g2000yqg (DOT) googlegroups.com...
Douglas, I removed the "New" keyword but the error persists.
Regarding the missing module referred in the error - do you know what
that is?
Is it a library or something else?
I have downloaded and installed MS Collaboration Data Objects 1.2.1 as
well as Microsoft Exchange Server MAPI Client.
both CDO.dll & CDOsys.dll appear in my System32 folder.
I have checked off CDO Library 1.21 and CDO for Windows 2000 Library
in the references.
The code compiles without errors - but the error still pops up on the
Set .....CreateObject
I must be overlooking or missing something else but I'm not sure what.
Do you have any further ideas? Thanks

On Nov 7, 6:15 pm, "Douglas J Steele"

NOSPAM_djsteele (AT) NOSPAM_gmail (DOT) com> wrote:
Not sure whether it's related to your error, but you do not use the
New
keyword in conjunction with Set. Try:

Dim objMessage As CDO.Message

Set objMessage = CreateObject("CDO.Message")

"Lou O" wrote in message

news:f3919cc9-5317-4703-b6cd-a6af6def7666 (AT) w20g2000prc (DOT) googlegroups.com...

I have been looking for a way to send an email from access with an
independent file attachment. In other words without using the
sendobject method which sends only access objects.
In this news group I came across the CDO Library method with very
simple code as below

Dim objMessage As New CDO.Message
Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "Example CDO Message"
objMessage.From = "m... (AT) my (DOT) com"
objMessage.To = "loosterh... (AT) gmail (DOT) com"
objMessage.TextBody = "This is some sample message text."
objMessage.AddAttachment "c:\temp\readme.txt"

However the code generates the following error running the
Set......CreateObject line

Run-time error '-2147024770(8007007e)':
Automation Error
The specified module could not be found.

Does anyone know what this error means?
Am I missing a class module that this method requires?
I have a suspicion that it refers to MS Outlook (not installed) but
I'm not sure.

Thanks for your help
Lou O

Thanks Jon
I followed the link and followed the tutorial.
But alas the same error pops up.
I know it's something stupid and obvious but it continues to elude me!
Would you mind posting your code behind this procedure to see if can
spot the obvious?
Lou

Reply With Quote
Reply




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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.