S
sallysmedly
Hi,
I have a page where a user can browse for and attach 2 files to an
email.
The email works fine when I try to send a selected file from the
server, but I have added in some script so that it sends the files the
user has selected, but this part won't work.
Any suggestions would be much appreciated.
emailtest.asp
<%
Dim objMail
Set objMail = Server.CreateObject("CDO.Message")
Set objConfig = Server.CreateObject("CDO.Configuration")
'Configuration:
objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort
objConfig.Fields(cdoSMTPServer)="auth.smtp.mydomain.co.uk"
objConfig.Fields(cdoSMTPServerPort)=25
objConfig.Fields(cdoSMTPAuthenticate)=cdoBasic
objConfig.Fields(cdoSendUserName) = "username"
objConfig.Fields(cdoSendPassword) = "password"
'Update configuration
objConfig.Fields.Update
Set objMail.Configuration = objConfig
objMail.From ="(e-mail address removed)"
objMail.To = "(e-mail address removed)"
objMail.Subject = "You have a new message"
objMail.TextBody = "You have a entry from "
'this bit doesn't work
for each file in Upload.Files
fn=File.ExtractFilename
objMail.AddAttachment Server.MapPath(fn),fn
next
'end of bit not working
'this does work, but only attaches a fixed file, rather than user
selected file
'objMail.AddAttachment "http://www.mydomian.com/code.htm"
objMail.Send
If Err.Number = 0 Then
Response.Write("Mail sent!")
Else
Response.Write("Error sending mail. Code: " & Err.Number)
Err.Clear
End If
Set objMail=Nothing
Set objConfig=Nothing
%>
form email:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<form action="emailtest.asp" method="post" enctype="multipart/form-
data" name="form1">
<p>
<input name="file1" type="file" id="file1">
</p>
<p>
<input type="file" name="file2" id="file2">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>
I have a page where a user can browse for and attach 2 files to an
email.
The email works fine when I try to send a selected file from the
server, but I have added in some script so that it sends the files the
user has selected, but this part won't work.
Any suggestions would be much appreciated.
emailtest.asp
<%
Dim objMail
Set objMail = Server.CreateObject("CDO.Message")
Set objConfig = Server.CreateObject("CDO.Configuration")
'Configuration:
objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort
objConfig.Fields(cdoSMTPServer)="auth.smtp.mydomain.co.uk"
objConfig.Fields(cdoSMTPServerPort)=25
objConfig.Fields(cdoSMTPAuthenticate)=cdoBasic
objConfig.Fields(cdoSendUserName) = "username"
objConfig.Fields(cdoSendPassword) = "password"
'Update configuration
objConfig.Fields.Update
Set objMail.Configuration = objConfig
objMail.From ="(e-mail address removed)"
objMail.To = "(e-mail address removed)"
objMail.Subject = "You have a new message"
objMail.TextBody = "You have a entry from "
'this bit doesn't work
for each file in Upload.Files
fn=File.ExtractFilename
objMail.AddAttachment Server.MapPath(fn),fn
next
'end of bit not working
'this does work, but only attaches a fixed file, rather than user
selected file
'objMail.AddAttachment "http://www.mydomian.com/code.htm"
objMail.Send
If Err.Number = 0 Then
Response.Write("Mail sent!")
Else
Response.Write("Error sending mail. Code: " & Err.Number)
Err.Clear
End If
Set objMail=Nothing
Set objConfig=Nothing
%>
form email:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
</head>
<body>
<form action="emailtest.asp" method="post" enctype="multipart/form-
data" name="form1">
<p>
<input name="file1" type="file" id="file1">
</p>
<p>
<input type="file" name="file2" id="file2">
</p>
<p>
<input type="submit" name="Submit" value="Submit">
</p>
</form>
</body>
</html>