简体   繁体   English

将附件从ASP Classic传递到.Net电子邮件Web服务

[英]Passing Attachments from ASP Classic to .Net Email Web Service

My company has a C# .Net based web service for sending email. 我公司有一个基于C#.Net的Web服务,用于发送电子邮件。 This web service does not currently support attachments. 该Web服务当前不支持附件。 We have many old ASP Classic pages that are still using CDONTS for sending emails (including ones with attachments). 我们有许多旧的ASP Classic页面仍在使用CDONTS发送电子邮件(包括带有附件的电子邮件)。 My current task is to find out if we can add attachment support to the web service such that we can replace the ASP Classic CDONTS with calls to the web service. 我当前的任务是确定是否可以向Web服务添加附件支持,以便可以用对Web服务的调用替换ASP Classic CDONTS。 What I'm getting hung up on is this: is it possible to pass those files that need to be attached to the web service from ASP Classic. 我要挂断的是:是否可以从ASP Classic传递那些需要附加到Web服务的文件。

  1. I know how to call a web service from ASP Classic; 我知道如何从ASP Classic调用Web服务。 I can already use the existing web service from Classic when I don't need attachments. 当我不需要附件时,我已经可以使用Classic的现有Web服务。
  2. I know that I could use CDOSYS or other ASP Classic methods to send the email: I'm being asked to use this existing web service. 我知道我可以使用CDOSYS或其他ASP Classic方法发送电子邮件:被要求使用此现有Web服务。
  3. I've seen lots of examples of web services taking in files as a byte array: how would you create and send that byte array from ASP Classic? 我已经看到许多Web服务将文件作为字节数组接收的示例:如何从ASP Classic创建和发送该字节数组?
  4. I've also seen lots of email web service examples where the service just takes in a file path. 我还看到了许多电子邮件Web服务示例,其中服务仅采用文件路径。 Am I wrong in thinking that this would be problematic if you're running the web service on a different machine? 我是否认为如果在另一台计算机上运行Web服务会出现问题,这是错误的吗? The path you send would have to be accessible to the web service host. Web服务主机必须可以访问您发送的路径。

Any help is appreciate: I've found lots of articles describing half of what I need to do, or only approaching it from a .Net-to-.Net angle. 感谢您的帮助:我发现很多文章描述了我需要做的事情的一半,或者仅从.Net到.Net的角度介绍它。

you could use the adodb.stream object to convert binary data into a byte array: 您可以使用adodb.stream对象将二进制数据转换为字节数组:

Function ReadByteArray(strFileName)
    Const adTypeBinary = 1
    Dim bin : Set bin = Server.CreateObject("ADODB.Stream")
    bin.Type = adTypeBinary
    bin.Open
    bin.LoadFromFile strFileName
    ReadByteArray = bin.Read
End Function

doc of adodb.stream adodb.stream的文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM