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-13-2006, 09:35 PM MapPath question
Average Talker

Posts: 26
Trades: 0
Hi guys,
I am trying to send an email with attachment and finally with your help it works fine, file uploads to server first and then goes to email as an attachment but I did "hard code" the file name, and I don't know how to get the file name from

objCDO.AddAttachment Server.MapPath("\contact\footer.htm")
server for attach part!

I really appreciate if you help me on this part.

Many thanks,
Elham

------------ 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\"
Response.write("<hr>")
%>
<%
SUB sendmail( fromWho, toWho, 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 (Server.MapPath("\contact\")& Upload.Form("toAttachment"))
objCDO.AddAttachment Server.MapPath("\contact\footer.htm")
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, 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, 11:09 PM Re: MapPath question
Super Talker

Posts: 144
Trades: 0
don't use mapPath in the sub, use it on the variables you pass to the sub. remember that "/contact" will look to : root/contact

also, u are still using Upload.Form() as your attachment that should be the file object and the file object has a path member which you can reference the complete path from. refer to the other thread.
__________________
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!
 
Old 04-14-2006, 03:42 AM Re: MapPath question
Average Talker

Posts: 26
Trades: 0
Many thaks for your help. Can you please see I have done exactly what you suggested.

Thanks,
Elham
----------------------------

<!-- 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\"
Response.write("<hr>")
%>
<%
SUB sendmail( fromWho, toWho, AddAttachment1, 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 (Server.MapPath("\contact\")& Upload.Form("toAttachment"))
objCDO.AddAttachment AddAttachment1
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"
AddAttachment1= Upload.Files("toAttachment").path
Subject = TRIM( Upload.Form( "Subject" ) )
Body = TRIM( Upload.Form( "Body") )
send_mail = Upload.Form( "send_mail")
If send_mail <> "" THEN
sendMail fromWho, toWho, AddAttachment1, Subject, Body
'Server.MapPath("\contact\")
'Cleanup
Set ObjCDO = Nothing
Set iConf = Nothing
Set Flds = Nothing
END IF
%>

</BODY>
</HTML>
elham is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to MapPath question
 

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.12799 seconds with 12 queries