我一直在使用CDOSys对象进行经典ASP中的电子邮件发送,它可以很好地处理单个文件附件但对多个附件无法正常工作。它取了所有附件的最后一个附件文件的名称和文件扩展名。请让我知道问题出在哪里。我的代码是
Function Send_Email_WithAttachments(strFrom,strTo,strSubject,strBody,strCC,strBCC,arrFiles,arrText)
Dim mailObj,I
Set mailObj=CreateObject("CDO.Message")
With mailObj
.Subject=strSubject
.From=strFrom
.To=strTo
If isValidEmail(strCC) = True Then
.CC = strCC
End If
If isValidEmail(strBCC) = True Then
.BCc = strBCC
End If
.HTMLBody = strBody
If IsArray(arrFiles) = True Then
For I=0 To UBound(arrFiles)
.AddAttachment arrFiles(I)
With mailObj.Attachments(1).Fields
.Item(cdoContentDisposition) = "attachment;filename="&arrText(I)
.Update
End With
Next
End If
.Send
End With
Set mailObj=Nothing
End Function
Thanks, Ravi
答案 0 :(得分:1)
你在循环中解决了相同的附件(索引== 1):
With mailObj.Attachments(1).Fields
应该是;
With mailObj.Attachments(I).Fields