简体   繁体   中英

Passing Attachments from ASP Classic to .Net Email Web Service

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.

  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. 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.
  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?
  4. 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.

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.

you could use the adodb.stream object to convert binary data into a byte array:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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