无法使用ASP CDO在电子邮件中附加附件 [英] Can't attach attachments in email using ASP CDO

查看:64
本文介绍了无法使用ASP CDO在电子邮件中附加附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我尝试从HTML页面中获取已检查的文件,然后将这些PDF

文件作为附件发送。它只能发送电子邮件,没有PDF文件

附加。有人可以指出我的错误吗?


我的想法是:

当人们检查HTML页面中的PDF文件的复选框时,它是

将文件的名称传输到ASP页面。然后,它会将它附在

的电子邮件中。


ASP文件 - myMail.asp

------ ---------------


<%@ Language = VBScript%>

<! - 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"

- >


<%

SUB sendmail(toWho,Subject,身体)

昏暗的objCDO

昏暗的iConf

Dim Flds


Const cdoSendUsingPort = 2


设置objCDO = Server.CreateObject(" CDO.Message")

设置iConf = Server.CreateObject(" CDO.Configuration")


设置Flds = iConf.Fields

使用Flds

..Item(cdoSendUsingMethod)= cdoSendUsingPort

.. Item(cdoSMTPServer)=" newserver"

..Item(cdoSMTPServerPort)= 25

..Item(cdoSMTPconnectiontimeout)= 10

。 。更新

结束


设置objCDO.Configuration = iConf


objCDO.From =" in * *@axiomcollege.com.au"

objCDO.To = toWho

objCDO.Subject = Subject


courseOutline = Request。表格(巴士)

courseOutline = Split(courseOutline,",& QUOT; )


对于courseOutline中的每个成员

filepath = Server.Path(" /")&会员

objCDO.AddAttachment filepath

下一页


objCDO.TextBody = Body

objCDO.Send

END SUB


toWho = TRIM(Request.Form(To))

Subject = TRIM(请求。表格(主题))

Body = TRIM(Request.Form(Body))

IF toWho<> ""那么

发送邮件给谁,主题,身体


''清理

设置ObjCDO =没什么

设置iConf = Nothing

设置Flds = Nothing

Response.Write发送电子邮件

END IF

%>


< html>

< body>

< form action =" mymail.asp"方法= QUOT;交" ID = Form1>

< table cellspacing = 0 cellpadding = 2>

< tr>

< td>来自: in**@domain.com.au < / td>

< / tr> ;

< tr>

< td>收件人:< input type =" text"名称= QUOT;至"大小= QUOT; 20" ID = Text1>< / td>

< / tr>

< tr>

< td>主题:< input type =" text"命名= QUOT受试者QUOT; size =" 20"

ID = Text2>< / td>

< / tr>

< tr>

< td>附件:< / td>

< td>

<%

courseOutline = Request.Form(" Bus")

courseOutline = Split(courseOutline,",")

对于courseOutline中的每个成员

response.write member& " br>"

下一页

%>

< / td>

< ; / tr>

< tr>

< td>消息:< / td>

< / tr>

< tr>

< td>< textarea rows =" 10"名称= QUOT;机体" cols =" 40"

ID = Textarea1>< / textarea>< / td>

< / tr>

< ; tr>

< td colspan = 2>< input type ="提交"名称= QUOT;发送和QUOT; Value =" Send Email"

Hi

I try to grab the checked files from HTML page and then send those PDF
files as attachments. It can just send email, there are no PDF files
attached. Can anybody point out my error?

My idea is:
When people check the check boxes in HTML page for the PDF files, it
will transfer the files'' name to ASP page. Then, it will attach it in
the email.

ASP file - myMail.asp
---------------------

<%@ Language=VBScript %>
<!--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"
-->

<%
SUB sendmail( 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) = "newserver"
..Item(cdoSMTPServerPort) = 25
..Item(cdoSMTPconnectiontimeout) = 10
..Update
End With

Set objCDO.Configuration = iConf

objCDO.From = "in**@axiomcollege.com.au"
objCDO.To = toWho
objCDO.Subject = Subject

courseOutline = Request.Form( "Bus" )
courseOutline = Split( courseOutline, "," )

For Each member in courseOutline
filepath = Server.Path("/") & member
objCDO.AddAttachment filepath
Next

objCDO.TextBody = Body
objCDO.Send
END SUB

toWho = TRIM( Request.Form("To") )
Subject = TRIM( Request.Form("Subject") )
Body = TRIM( Request.Form("Body") )
IF toWho <> "" THEN
sendMail toWho, Subject, Body

''Cleanup
Set ObjCDO = Nothing
Set iConf = Nothing
Set Flds = Nothing
Response.Write "Email Sent"
END IF
%>

<html>
<body>
<form action="mymail.asp" method="post" ID=Form1>
<table cellspacing=0 cellpadding=2>
<tr>
<td> From: in**@domain.com.au </td>
</tr>
<tr>
<td> To: <input type="text" name="To" size="20" ID=Text1></td>
</tr>
<tr>
<td> Subject: <input type="text" name="Subject" size="20"
ID=Text2></td>
</tr>
<tr>
<td> Attachments: </td>
<td>
<%
courseOutline = Request.Form( "Bus" )
courseOutline = Split( courseOutline, "," )
For Each member in courseOutline
response.write member & "<br>"
Next
%>
</td>
</tr>
<tr>
<td>Message: </td>
</tr>
<tr>
<td><textarea rows="10" name="Body" cols="40"
ID=Textarea1></textarea></td>
</tr>
<tr>
<td colspan=2><input type="Submit" Name="Send" Value="Send Email"

< / td>
</td>



< / tr>

< tr>

< td>

<%

msm = Request.Form(" Test")

回复.write msm

%>

< / td>

< / tr>

< / table>

< / form>

< / body>

< / html>

HTML文件 - mailform.htm

---------

< html>

< head>

< title>索取更多信息< / title>

< / head>

< body>

< form action =" mymail.asp" method =" post">

< p>

MS Outlook PDF文件

< input type ="复选框"值= QUOT; outlook.pdf"名称= QUOT;公交" />

< / p>

< p>

MS Word PDF文件

< input type =" checkbox"值= QUOT; word.pdf"名称= QUOT;公交" />

< / p>

< p>

MS Excel PDF文件

< input type =" checkbox"值= QUOT; excel.pdf"名称= QUOT;公交" />

< / p>

< p>

< input type =" submit"值= [提交"命名= [提交" />

< / p>

< / form>

< / body>

< / html>


</tr>
<tr>
<td>
<%
msm = Request.Form("Test")
response.write msm
%>
</td>
</tr>
</table>
</form>
</body>
</html>
HTML file - mailform.htm
---------
<html>
<head>
<title>Request for More info</title>
</head>
<body>
<form action="mymail.asp" method="post">
<p>
MS Outlook PDF Document
<input type="checkbox" value="outlook.pdf" name="Bus" />
</p>
<p>
MS Word PDF Document
<input type="checkbox" value="word.pdf" name="Bus" />
</p>
<p>
MS Excel PDF Document
<input type="checkbox" value="excel.pdf" name="Bus" />
</p>
<p>
<input type="submit" value="Submit" name="Submit" />
</p>
</form>
</body>
</html>

推荐答案

您是否确认您的代码认为应附加某个文件?

< %

''...

courseOutline = Request.Form(" Bus")

courseOutline = Split(courseOutline,", ")


RESPONSE.WRITE UBOUND(courseOutline)

RESPONSE.END


对于courseOutline中的每个成员

filepath = Server.Path(" /")&会员

objCDO.AddAttachment filepath

下一页

''...

%>


雷在工作

" tabonni" < TA ***** @ yahoo.com>在消息中写道

news:fb ************************** @ posting.google.c om ...
Have you confirmed that your code thinks that some file should be attached?
<%
''...
courseOutline = Request.Form( "Bus" )
courseOutline = Split( courseOutline, "," )

RESPONSE.WRITE UBOUND(courseOutline)
RESPONSE.END

For Each member in courseOutline
filepath = Server.Path("/") & member
objCDO.AddAttachment filepath
Next
''...
%>

Ray at work
"tabonni" <ta*****@yahoo.com> wrote in message
news:fb**************************@posting.google.c om...


我尝试从HTML页面中获取已检查的文件,然后将这些PDF
文件作为附件发送。它只能发送电子邮件,没有附加的PDF文件。任何人都可以指出我的错误吗?

我的想法是:
当人们检查HTML页面中的PDF文件的复选框时,它会将文件的名称转移到ASP页面。然后,它会将它附在电子邮件中。

ASP文件 - myMail.asp
------------------ ---

<%@语言= VBScript%>
<! - 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类型库>
- >

<%
SUB sendmail(toWho,Subject,Body)
Dim objCDO
Dim iConf
Dim Flds

Const cdoSendUsingPort = 2

设置objCDO = Server.CreateObject(" CDO.Message")
设置iConf = Server .CreateObject(" CDO.Configuration")
设置Flds = iConf.Fields
使用Flds
。Item(cdoSendUsingMethod)= cdoSendUsingPort
.Item(cdoSMTPServer) =" newserver"
.Item(cdoSMTPServerPort)= 25
.Item(cdoSMTPconnectiontimeout)= 10
。更新
结束

设置objCDO。配置= iConf

objCDO.From =" in ** @ axiomcollege.com.au"
objCDO.To = toWho
objCDO.Subject = Subject

courseOutline = Request.Form(" Bus")
courseOutline = Split(courseOutline,",")

对于courseOutline中的每个成员
filepath = Server .Path(" /")&成员
objCDO.AddAttachment filepath
下一步
Hi

I try to grab the checked files from HTML page and then send those PDF
files as attachments. It can just send email, there are no PDF files
attached. Can anybody point out my error?

My idea is:
When people check the check boxes in HTML page for the PDF files, it
will transfer the files'' name to ASP page. Then, it will attach it in
the email.

ASP file - myMail.asp
---------------------

<%@ Language=VBScript %>
<!--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"
-->

<%
SUB sendmail( 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) = "newserver"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPconnectiontimeout) = 10
.Update
End With

Set objCDO.Configuration = iConf

objCDO.From = "in**@axiomcollege.com.au"
objCDO.To = toWho
objCDO.Subject = Subject

courseOutline = Request.Form( "Bus" )
courseOutline = Split( courseOutline, "," )

For Each member in courseOutline
filepath = Server.Path("/") & member
objCDO.AddAttachment filepath
Next



我使用For Each ...Next循环测试了courseOutline数组

我在HTML页面中选择的所有项目都在courseOutline Array中。

我不知道为什么我仍然无法将这些文件作为附件附加在

电子邮件。也没有错误弹出。任何想法?


干杯


" Ray Costanzo [MVP]" <我的第34号商业广告的名字>在消息新闻中写道:< #A ************** @ TK2MSFTNGP11.phx.gbl> ...
I tested the courseOutline array using For Each..Next Loop
All items I selected in the HTML page are in the courseOutline Array.
I don''t know why I still can''t attach those files as attachments in
email. There are no error pop out either. Any idea?

Cheers

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in message news:<#A**************@TK2MSFTNGP11.phx.gbl>...
你确认你的代码认为有些文件应该附上?

<%
''...
courseOutline = Request.Form(" Bus")
courseOutline = Split(courseOutline, ",")

RESPONSE.WRITE UBOUND(courseOutline)
RESPONSE.END

对于courseOutline中的每个成员
filepath = Server.Path (" /)&会员
objCDO.AddAttachment filepath
下一页
''...
%>

Ray在工作

" ; tabonni" < TA ***** @ yahoo.com>在消息中写道
新闻:fb ************************** @ posting.google.c om ...
Have you confirmed that your code thinks that some file should be attached?
<%
''...
courseOutline = Request.Form( "Bus" )
courseOutline = Split( courseOutline, "," )

RESPONSE.WRITE UBOUND(courseOutline)
RESPONSE.END

For Each member in courseOutline
filepath = Server.Path("/") & member
objCDO.AddAttachment filepath
Next
''...
%>

Ray at work
"tabonni" <ta*****@yahoo.com> wrote in message
news:fb**************************@posting.google.c om...


我尝试从HTML页面中获取已检查的文件,然后将这些PDF
文件作为附件发送。它只能发送电子邮件,没有附加的PDF文件。任何人都可以指出我的错误吗?

我的想法是:
当人们检查HTML页面中的PDF文件的复选框时,它会将文件的名称转移到ASP页面。然后,它会将它附在电子邮件中。

ASP文件 - myMail.asp
------------------ ---

<%@语言= VBScript%>
<! - 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类型库>
- >

<%
SUB sendmail(toWho,Subject,Body)
Dim objCDO
Dim iConf
Dim Flds

Const cdoSendUsingPort = 2

设置objCDO = Server.CreateObject(" CDO.Message")
设置iConf = Server .CreateObject(" CDO.Configuration")
设置Flds = iConf.Fields
使用Flds
。Item(cdoSendUsingMethod)= cdoSendUsingPort
.Item(cdoSMTPServer) =" newserver"
.Item(cdoSMTPServerPort)= 25
.Item(cdoSMTPconnectiontimeout)= 10
。更新
结束

设置objCDO。配置= iConf

objCDO.From =" in ** @ axiomcollege.com.au"
objCDO.To = toWho
objCDO.Subject = Subject

courseOutline = Request.Form(" Bus")
courseOutline = Split(courseOutline,",")

对于courseOutline中的每个成员
filepath = Server .Path(" /")&成员
objCDO.AddAttachment filepath
下一步
Hi

I try to grab the checked files from HTML page and then send those PDF
files as attachments. It can just send email, there are no PDF files
attached. Can anybody point out my error?

My idea is:
When people check the check boxes in HTML page for the PDF files, it
will transfer the files'' name to ASP page. Then, it will attach it in
the email.

ASP file - myMail.asp
---------------------

<%@ Language=VBScript %>
<!--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"
-->

<%
SUB sendmail( 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) = "newserver"
.Item(cdoSMTPServerPort) = 25
.Item(cdoSMTPconnectiontimeout) = 10
.Update
End With

Set objCDO.Configuration = iConf

objCDO.From = "in**@axiomcollege.com.au"
objCDO.To = toWho
objCDO.Subject = Subject

courseOutline = Request.Form( "Bus" )
courseOutline = Split( courseOutline, "," )

For Each member in courseOutline
filepath = Server.Path("/") & member
objCDO.AddAttachment filepath
Next



好吧,现在是你调试的时候,通过创建一个测试asp页面只是试图将
附加一个小文本文件到邮件对象并尽可能简单。

尝试缩小问题的范围,直到找到它为止。


雷在工作


" tabonni" < TA ***** @ yahoo.com>在消息中写道

news:fb ************************** @ posting.google.c om ...
Well, now is when you debug, by creating a test asp page that just tries to
attach one small text file to a mail object and is as simple as possible.
Try to narrow down where the problem may be until you find it.

Ray at work

"tabonni" <ta*****@yahoo.com> wrote in message
news:fb**************************@posting.google.c om...
我使用For Each ...Next循环测试了courseOutline数组
我在HTML页面中选择的所有项目都在courseOutline Array中。
我不知道为什么我仍然无法将这些文件作为附件附在
电子邮件中。也没有错误弹出。有什么想法吗?

雷·科斯坦佐[MVP] <我的第34号商业广告的名字>在
消息新闻中写道:< #A ************** @ TK2MSFTNGP11.phx.gbl> ...
I tested the courseOutline array using For Each..Next Loop
All items I selected in the HTML page are in the courseOutline Array.
I don''t know why I still can''t attach those files as attachments in
email. There are no error pop out either. Any idea?

Cheers

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:<#A**************@TK2MSFTNGP11.phx.gbl>...
你确认你的代码认为某些文件应该附加?

<%
''...
courseOutline = Request.Form(" Bus")
courseOutline = Split(courseOutline,",")

RESPONSE.WRITE UBOUND(courseOutline)
RESPONSE.END

对于courseOutline中的每个成员
filepath = Server.Path(" /")&会员
objCDO.AddAttachment filepath
下一页
''...
%>

Ray在工作

" ; tabonni" < TA ***** @ yahoo.com>在消息中写道
新闻:fb ************************** @ posting.google.c om ...
Have you confirmed that your code thinks that some file should be
attached?
<%
''...
courseOutline = Request.Form( "Bus" )
courseOutline = Split( courseOutline, "," )

RESPONSE.WRITE UBOUND(courseOutline)
RESPONSE.END

For Each member in courseOutline
filepath = Server.Path("/") & member
objCDO.AddAttachment filepath
Next
''...
%>

Ray at work
"tabonni" <ta*****@yahoo.com> wrote in message
news:fb**************************@posting.google.c om...
>嗨
>
>我尝试从HTML页面中获取已检查的文件,然后发送这些PDF
>文件作为附件。它只能发送电子邮件,没有PDF文件
>连接。任何人都可以指出我的错误吗?
>
>我的想法是:
>当人们检查HTML页面中的PDF文件的复选框时,它是
>将文件的名称传输到ASP页面。然后,它将附加在
>电子邮件。
>
> ASP文件 - myMail.asp
> ---------------------
>
> <%@ Language = VBScript%>
> <! - METADATA TYPE =" typelib"
> UUID = QUOT; CD000000-8B95-11D1-82DB-00C04FB1625D" NAME =" Windows的CDO
>图书馆" - >
> <! - METADATA TYPE =" typelib"
> UUID = QUOT; 00000205-0000-0010-8000-00AA006D2EA4" NAME =" ADODB类型库"
> - >
>
> <%
> SUB sendmail(toWho,Subject,Body)
> Dim objCDO
>昏暗的iConf
> Dim Flds
>
> Const cdoSendUsingPort = 2
>
>设置objCDO = Server.CreateObject(" CDO.Message")
>设置iConf = Server.CreateObject(" CDO.Configuration")
>
>设置Flds = iConf.Fields
>随着Flds
> .Item(cdoSendUsingMethod)= cdoSendUsingPort
> .Item(cdoSMTPServer)=" newserver"
> .Item(cdoSMTPServerPort)= 25
> .Item(cdoSMTPconnectiontimeout)= 10
> 。更新
>结束
>
>设置objCDO.Configuration = iConf
>
> objCDO.From =" in ** @ axiomcollege.com.au"
> objCDO.To = toWho
> objCDO.Subject =主题
>
> courseOutline = Request.Form(" Bus")
> courseOutline = Split(courseOutline,",")
>
>对于courseOutline中的每个成员
> filepath = Server.Path(" /")&会员
> objCDO.AddAttachment filepath
>下一步
> Hi
>
> I try to grab the checked files from HTML page and then send those PDF
> files as attachments. It can just send email, there are no PDF files
> attached. Can anybody point out my error?
>
> My idea is:
> When people check the check boxes in HTML page for the PDF files, it
> will transfer the files'' name to ASP page. Then, it will attach it in
> the email.
>
> ASP file - myMail.asp
> ---------------------
>
> <%@ Language=VBScript %>
> <!--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"
> -->
>
> <%
> SUB sendmail( 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) = "newserver"
> .Item(cdoSMTPServerPort) = 25
> .Item(cdoSMTPconnectiontimeout) = 10
> .Update
> End With
>
> Set objCDO.Configuration = iConf
>
> objCDO.From = "in**@axiomcollege.com.au"
> objCDO.To = toWho
> objCDO.Subject = Subject
>
> courseOutline = Request.Form( "Bus" )
> courseOutline = Split( courseOutline, "," )
>
> For Each member in courseOutline
> filepath = Server.Path("/") & member
> objCDO.AddAttachment filepath
> Next



这篇关于无法使用ASP CDO在电子邮件中附加附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆