将文件上传到服务器,然后附加到电子邮件并以 asp 格式发送 [英] Upload file to server, then attach to email and send in asp

查看:21
本文介绍了将文件上传到服务器,然后附加到电子邮件并以 asp 格式发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个根据用户输入上传文件的应用程序..将图像上传到我的网络服务器上的文件夹.我现在希望脚本在上传后发送附有图片的电子邮件

I am having a application that uploads files according to the user input.. that upload an image to a folder on my web server. I now want the script to send an email with the image attached after it's uploaded

非常感谢任何帮助....

Any help is really appreciated....

推荐答案

我强烈建议您在代码中执行此操作,并且不要监视服务器上的文件夹是否有任何更改!例如,上传完成后使用 CDOSYS 发送电子邮件

I strongly suggest you do this in the code and don't monitor the folder on your server for any changes! EG, after the upload is complete send the email using CDOSYS

我将假设您知道文件名和文件位置,并且可以将此路径存储为变量.我不知道你选择了什么变量名,所以我将使用一个名为 uploadedFilePath

I am going to assume you know the file name and file location and can store this path as a variable. I don't know what variable name you chose so I will use a variable called uploadedFilePath

<%
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")

ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mail.yourDomainName.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="myEmail@myDomainName.com"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="myPassword"

ObjSendMail.Configuration.Fields.Update

ObjSendMail.To = "someone@AntoherDomain.com"
ObjSendMail.Subject = "Upload complete"
ObjSendMail.From = "me@myDomainName.com"
ObjSendMail.AddAttachment = uploadedFilePath

ObjSendMail.HTMLBody = "<p>Hi,<br /> A file has been uploaded!</p>"    
ObjSendMail.Send    
Set ObjSendMail = Nothing
%> 

这篇关于将文件上传到服务器,然后附加到电子邮件并以 asp 格式发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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