asp使用Jmail发送带doc类型附件的邮件

来源:互联网 发布:天书世界 血盾数据 编辑:程序博客网 时间:2024/05/16 07:31
<%'生成doc文档的方法Sub CreateWord(filename,lessonCode,stuName,lessonDate)Dim fso, MyFileSet fso = CreateObject("Scripting.FileSystemObject")Set MyFile = fso.CreateTextFile(filename, True)MyFile.WriteLine("您的听课信息如下:")MyFile.WriteLine("申请者:"&stuName)MyFile.WriteLine("听课证编号:"&lessonCode)MyFile.WriteLine("课程时间:"&lessonDate)MyFile.CloseSet fso = Nothing End Sub '发送邮件(带附件)Public Function SendMail(MailTitle,GetMailMan,MailBody,SendFrom,SendName,SendUser,SendPwd,SendSmtp,Attachment)'On Error Resume Nextif SendName="" thenSendName="邮件测试"end ifif SendFrom="" thenSendFrom = "发件人邮箱"end ifif SendUser="" thenSendUser = "发件人邮箱" end ifif SendPwd="" thenSendPwd = "发件人邮箱密码"end ifif SendSmtp="" thenSendSmtp = "邮箱smtp地址"end ifdim JmsSet Jms = Server.CreateObject("jmail.Message")Jms.Charset = "GB2312" 'Jms.ContentType = "text/html"Jms.Subject = MailTitle Jms.AddRecipient(GetMailMan)Jms.HTMLBody=MailBodyif Attachment<>"" thenJms.AddAttachment Attachment,trueend ifJms.From = SendFrom Jms.FromName = SendName Jms.MailServerUserName = SendUserJms.MailServerPassWord = SendPwdJms.Send(SendSmtp)Jms.Close()Set Jms = NothingIf Err.number <> 0 then    'response.Write( "mail send failed!"& Err.DescriptionElse)else'response.Write("mail send successed!")End If'Response.Write err.Description'Response.endEnd Function%>


原创粉丝点击