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

时间:2021-04-23 02:02:51

My company has a C# .Net based web service for sending email. This web service does not currently support attachments. We have many old ASP Classic pages that are still using CDONTS for sending emails (including ones with attachments). 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. 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.

我的公司有一个基于C#.Net的网络服务,用于发送电子邮件。此Web服务当前不支持附件。我们有许多旧的ASP Classic页面仍在使用CDONTS发送电子邮件(包括带附件的电子邮件)。我目前的任务是找出是否可以向Web服务添加附件支持,以便我们可以通过调用Web服务来替换ASP Classic CDONTS。我要挂断的是:是否可以将需要从ASP Classic附加到Web服务的文件传递给它。

  1. I know how to call a web service from ASP Classic; I can already use the existing web service from Classic when I don't need attachments.
  2. 我知道如何从ASP Classic调用Web服务;当我不需要附件时,我已经可以使用Classic中的现有Web服务。

  3. 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.
  4. 我知道我可以使用CDOSYS或其他ASP Classic方法发送电子邮件:我被要求使用这个现有的Web服务。

  5. 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?
  6. 我已经看到很多Web服务作为字节数组接收文件的例子:你将如何从ASP Classic创建和发送该字节数组?

  7. I've also seen lots of email web service examples where the service just takes in a file path. Am I wrong in thinking that this would be problematic if you're running the web service on a different machine? The path you send would have to be accessible to the web service host.
  8. 我也看过很多电子邮件Web服务示例,其中服务只是在文件路径中。如果您在另一台计算机上运行Web服务,我认为这会有问题吗?您发送的路径必须可供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角度接近它。

1 个解决方案

#1


1  

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的文档

#1


1  

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的文档