473,324 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

CDO message attach files

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.mydomai n.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 ="xx*@mydomain.com"
objMail.To = "xx*@mydomain.com"
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>

Jun 18 '07 #1
0 3740

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: praba kar | last post by:
Dear All, I am new to python world. I have pasted my code which I used it to build rfc822 format mails for webbased mailing system task(which is like to yahoo.com web interface). Now I am...
1
by: vijaygparikh | last post by:
HI i am writting a code for open default mail client and it works fine. i want to attach a file with the default mail client but file is not attached with "mailto:" option. If any one has idea...
1
by: kevcar40 | last post by:
i have a form that i want to attach files to as hyperlinks the problem is there could be upto 10 files attached to the form or maybe none How can i go about 1 creating the attachements and...
7
by: Greg P | last post by:
I know this is a long post, please bear with me. I have been working on this all weekend to no avail although I have done a good amount of research (see most pertinent links that I've looked at...
6
by: a | last post by:
What is the best way to construct an email in python and also attach a html file the html file to be attached is not on disk, but should be dynamically constructed in the python script I want...
2
by: calebmichaud | last post by:
Hi I am having trouble understanding how to attach a file or files to a record. I want to (in form view0 allow the user to attach one or more than one file to the associated record, and then...
5
by: rrkrishna24 | last post by:
Can someone guide how to code in simple HTML, how to browse the files and attach them. That is, when I click a button say "Attach", a window should be opened with which one can browse the files in...
2
ddtpmyra
by: ddtpmyra | last post by:
Hi, Can I attach files on a mysql tables? If yes what type of field is it and how to attach a file or doc? thanks, DM
1
by: ziycon | last post by:
I'm getting this error when i try to attach a DB:
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.