Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Old 04-12-2006, 09:50 PM Attachment error
Average Talker

Posts: 26
Trades: 0
Hi guys,
I am trying to email a file and I learned that I have to upload it to server first and then attach to email. First part works fine and I can see the file in server but second part (attachment) doesn;t work could you please see where I am doing wrong?

I tried every thing
Many thanks for your help.
Elham

--------------------- error -------------------------
2 file(s) uploaded to C:\Inetpub\wwwroot\stecs-dev\contact\

Microsoft VBScript runtime
error '800a01c2'
Wrong number of arguments or invalid property assignment: 'objCDO.AddAttachment' /UploadScript11.asp, line 42

--------------------- Code ------------------------
<!-- AspUpload Code samples: UploadScript1.asp -->
<!-- Invoked by Form1.asp -->
<!-- Copyright (c) 2001 Persits Software, Inc. -->
<!-- http://www.persits.com -->
<!--METADATA TYPE="typelib" UUID="CD000000-8B95-11D1-82DB-00C04FB1625D" NAME="CDO for Windows Library" -->
<!--METADATA TYPE="typelib" UUID="00000205-0000-0010-8000-00AA006D2EA4" NAME="ADODB Type Library" -->
<HTML>
<BODY>
<%
Set Upload = Server.CreateObject("Persits.Upload")
Count = Upload.Save("C:\Inetpub\wwwroot\stecs-dev\contact\")
Response.Write Count & " file(s) uploaded to C:\Inetpub\wwwroot\stecs-dev\contact\"
%>
<%
SUB sendmail( fromWho, toWho, AddAttachment, Subject, Body )
Dim objCDO
Dim iConf
Dim Flds
Const cdoSendUsingPort = 2
Set objCDO = Server.CreateObject("CDO.Message")
Set iConf = Server.CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
With Flds
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = MailServer
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPconnectiontimeout) = 10
.Update
End With
Set objCDO.Configuration = iConf
objCDO.From = fromWho
objCDO.To = toWho
objCDO.Subject = Subject
objCDO.AddAttachment
objCDO.TextBody = Body
objCDO.Send
END SUB

Dim Domainname
Dim MailServer
Dim From
Dim subject1
Domainname = "webdev.stecs.com"
MailServer = Upload.Form("MailServer")
subject1 = "IDS-7934969 - "
fromWho = Upload.Form( "fromWho") + "@hotmail.com"
toWho = Upload.Form( "toWho") + "@stecs.com"
AddAttachment= Upload.Form("toAttachment")
Subject = TRIM( Upload.Form( "Subject" ) )
Body = TRIM( Upload.Form( "Body") )
send_mail = Upload.Form( "send_mail")
If send_mail <> "" THEN
sendMail fromWho, toWho, AddAttachment , Subject, Body
'Cleanup
Set ObjCDO = Nothing
Set iConf = Nothing
Set Flds = Nothing
END IF
%>

</BODY>
</HTML>
elham is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-13-2006, 01:32 AM Re: Attachment error
Super Talker

Posts: 144
Trades: 0
I would imagine that you need to use the File object and pass the PATH of the uploaded file ON THE SERVER to your sendmail sub routine. Looks like you are passing the value of the form field, which would most likely contain the path as it is related to the users computer, not the server.

try, Upload.Files("toAttachment").path instead of Upload.Form

http://www.aspupload.com/object_file.html

ALSO

your sendmail sub routine doesn't seem to actually be adding the attachment. though you are sepcifying, AddAttachment, you are not providing the path to the attachment which to add. Your variable naming is contradicting so this may confuse you, but here is what I think (given your code) it should look like..

objCDO.AddAttachment AddAttachment

since 'AddAttachment' SHOULD contain the path to the attachment you wish to upload. I would rename those arguments in the sub.

http://www.aspemail.com/manual_03.html
__________________
create.vibe

Please login or register to view this content. Registration is FREE
createvibe.com is offline
Reply With Quote
View Public Profile Visit createvibe.com's homepage!
 
Reply     « Reply to Attachment error
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.45479 seconds with 12 queries