Wrox Programmer Forums
|
ASP CDO As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP CDO section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 10th, 2004, 02:42 AM
Registered User
 
Join Date: Dec 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to send email with attachment?

Okay this is so annoying me I am finally having to refrain from my pal google and move on to the mystical land of forums. :D

I am trying to get a asp-mailer setup that will send a specified attachment. I have tried both cdonts and cdosys methods ... both are giving me headaches.

And the best part is how incredibly helpful the error is: (Sarcasm Intended)

Error Type:
(0x80004005)
Unspecified error <-- They should change that error to ... "Good Luck!"
/knowledgetree/emailer-drivers.asp, line 90
I hilighted the above line in the code as well.

Here is the code I am working with:

Code:
<!-- These first two meta tag lines were added per a I suggestion I found on a forum somewhere.
I get the same error with or without them. And this is running on a WinXP Pro box BTW. -->



<%
Dim oAttach, DriverType, DriverVendor, DriverZip, email, html, oMail

DriverType    = request.form("type")
DriverVendor  = request.form("vendor")
DriverZip     = request.form("attached")

email         = request.form("email")

oAttach = "C:\tier1\knowledgetree\files\"
oAttach = oAttach & DriverType & "\"
oAttach = oAttach & DriverVendor & "\"
oAttach = oAttach & DriverZip

html = "Dear Subscriber:"
html = html & "<p>"
html = html & "<table>"
etc. etc...

Set oMail = Server.CreateObject("CDONTS.NewMail")

oMail.From       = "[email protected]"
oMail.To         = email
oMail.Subject    = "Requested Device Drivers"
oMail.BodyFormat = 1
oMail.MailFormat = 0
oMail.Importance = 1
oMail.Body       = html
oMail.Attachfile oAttach, "DevDrivers.zip", 1
%> 
Your Request Has Been Processed.
<P>
<a href="http://tier1/knowledgetree/bottom.asp">
<b>Home</b></a>
Thanks for any help
- Matthew
 
Old December 10th, 2004, 04:03 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Hi,

 While specifying the attachment, you have to give the full path.
This could be something like :

oMail.AttachFile Server.MapPath("/somedirectory/bla.txt")

' or you could specify the path exactly if you knew it like below
oMail.AttachFile ("C:\inetpub\wwwroot\somedirectory\bla.txt")


Om Prakash
 
Old December 10th, 2004, 05:50 AM
Registered User
 
Join Date: Dec 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am specifying the full path though. In the variable 'oAttach'.

Code:
Dim oAttach, DriverType, DriverVendor, DriverZip, email, html, oMail

DriverType    = request.form("type")
DriverVendor  = request.form("vendor")
DriverZip     = request.form("attached")

email         = request.form("email")

oAttach = "C:\tier1\knowledgetree\files\"
oAttach = oAttach & DriverType & "\"
oAttach = oAttach & DriverVendor & "\"
oAttach = oAttach & DriverZip
And if I replace:
oMail.Attachfile oAttach, "DevDrivers.zip", 1

With:
response.write = oAttach

It prints the full desired path flawlessly.

- Matthew
 
Old December 10th, 2004, 09:43 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Please use full path and not other parameters with this variable.

oAttach = "C:\tier1\knowledgetree\files\"
oAttach = oAttach & DriverType & "\"
oAttach = oAttach & DriverVendor & "\"
oAttach = oAttach & DriverZip

This variable should only contain full path and file name.

Om Prakash
 
Old December 11th, 2004, 12:23 AM
Registered User
 
Join Date: Dec 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What do you mean 'Other Parameters'? .... there are no other parameters.

Maybe I should explain this again.

I know that the variable 'oAttach' is storing correctly because when I call it using response.write ...
walla ... I get the following:

"C:\tier1\knowledgetree\files\usb\linksys\befcmu10 .zip"

So basically what that tells me is that:

oAttach = "C:\tier1\knowledgetree\files\" & DriverType & "\" & DriverVendor & "\" & DriverZip == "C:\tier1\knowledgetree\files\usb\linksys\befcmu10 .zip"

So ultimately what I really want to know is what the heck is the defference between:

oMail.Attachfile oAttach, "DevDrivers.zip", 1

and:

oMail.Attachfile "C:\tier1\knowledgetree\files\usb\linksys\befcmu10 .zip", "DevDrivers.zip", 1

If I cannot make it dynamic .... what's the point?

???
- Matthew
 
Old December 11th, 2004, 12:45 AM
Registered User
 
Join Date: Dec 2004
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
quote:' or you could specify the path exactly if you knew it like below
oMail.AttachFile ("C:\inetpub\wwwroot\somedirectory\bla.txt")
By the way ...

oMail.AttachFile ("C:\tier1\knowledgetree\files\usb\linksys\befcmu1 0.zip")

produces the same error.

- Matthew
 
Old January 7th, 2005, 04:29 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 479
Thanks: 0
Thanked 3 Times in 3 Posts
Send a message via MSN to surendran Send a message via Yahoo to surendran
Default

hi friend,

Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.From = "[email protected]"
objCDOMail.To = "[email protected]"
objCDOMail.Subject = "Hi Friends"
objCDOMail.BodyFormat= 0
objCDOMail.MailFormat = 0
objCDOMail.Body =str
objCDOMail.Importance = 2
objCDOMail.AttachFile("C:\Inetpub\wwwroot\mail\fil ename.htm")
objCDOMail.Send
Set objCDOMail = Nothing

suren

surendran
(Anything is Possible)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using vb6 to send email with attachment LeonMK Pro VB 6 3 August 25th, 2011 01:56 AM
Macro to send an email with an attachment in it samputha Excel VBA 2 August 13th, 2009 09:12 PM
how to send attachment with text message ashuphp PHP How-To 1 October 29th, 2007 06:08 PM
how to send email with attachment using JSP kirtesh4u J2EE 0 May 19th, 2007 01:17 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.