home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 March / CHIPCD_3_98.iso / software / testsoft / exchange / webdata / usa / lib / attach.inc < prev    next >
Text File  |  1997-08-25  |  4KB  |  115 lines

  1. <%
  2. '!--Microsoft Outlook Web Access-->
  3. '!--Attach.inc - File Upload Functions-->
  4. '!--Copyright (c) Microsoft Corporation 1993-1997. All rights reserved.-->
  5.  
  6. '==========================================================================
  7. ' GetWebTempDirectory
  8. ' Returns the directory where the exupload.dll deposits the file 
  9. '==========================================================================
  10.  
  11. Public Function GetWebTempDirectory()
  12.     On Error Resume Next
  13.     Set objRenderApp = Application( bstrRenderApp )
  14.     bstrSaveDirectory = objRenderApp.ConfigParameter("RFC1867SaveDirectory")
  15.     Set objRenderApp = nothing
  16.     GetWebTempDirectory = bstrSaveDirectory    
  17. End Function
  18.  
  19. '===========================================================================
  20. ' DeleteAttachments - Deletes attachments from attachment collection in msg
  21. ' bstrUrlDelete - Delete parameter from url delimeted by semicolons
  22. ' Example: delete=1;3  attachments 1 and 3 will be deleted
  23. ' objAttachColl - Active Messaging attachment collection
  24. '===========================================================================
  25.  
  26. Public Sub DeleteAttachments(bstrUrlDelete, objAttachColl)
  27.     On Error Resume Next
  28.     'url format = ;#;#;#;#
  29.  
  30.     start=1
  31.     pos=1
  32.     leng=1
  33.     totlen=len(urlDelete)
  34.  
  35.     do until pos >= totlen 
  36.         start = pos + 1
  37.         fin=instr(start,urlDelete,";")
  38.         if fin = 0 then fin = len(urlDelete) + 1
  39.         leng = fin - start        
  40.        x = cint(mid(urlDelete,start,leng))
  41.         objAttachColl.item(x).delete
  42.         pos = fin
  43.     loop
  44.  
  45.  
  46. End Sub
  47.  
  48. '==========================================================================================
  49. ' GetFileName - Returns the file name from the file path provided by exupload.dll
  50. '==========================================================================================
  51. Public Function GetFileName(bstrFilePath)
  52.     On Error Resume Next
  53.     fd = "\"
  54.     isoffset = 0
  55.     if isUNIX() then
  56.         fd="/"
  57.       
  58.     elseif isMac() then
  59.         fd=":"
  60.     end if
  61.  
  62.     pos = instrRev(ffname, fd, len(ffname))
  63.     
  64.     bstrFileName = Mid(ffname, pos + 1, len(ffname) - pos - 1)
  65.     'Check for quote in first character.
  66.     If Left(bstrFileName,1) = chr(34) then
  67.         bstrFileName = Right(bstrFileName, Len(bstrFileName) - 1)
  68.     End If
  69.     GetFileName = bstrFileName 
  70. End Function
  71.  
  72. '==========================================================================================
  73. ' GetFileExt - Returns the file extension from the file name provided by exupload.dll
  74. '==========================================================================================
  75. Public Function GetFileExt(bstrFileName)
  76.     On Error Resume Next
  77.     pos = instrRev(ffname, ".", len(ffname))
  78.     filestart=1
  79.     
  80.     GetFileExt = Mid(ffname,pos, len(ffname) - pos)
  81.  
  82. End Function 
  83.  
  84. '==========================================================================================
  85. ' AddAttachment
  86. ' objMsg - Active Messaging message object
  87. ' bstrTempFileName - Temp file name returned from exupload.dll
  88. ' bstrMimeType - Mime Type returned from exupload.dll
  89. ' bstrFilePath - File path returned from exupload.dll 
  90. '==========================================================================================
  91.  
  92. Public Function AddAttachment(objMsg, bstrTempFileName, bstrMimeType, bstrFilePath)
  93.     On Error Resume Next
  94.     Set objAttachColl = objMsg.Attachments
  95.     bstrTempFilePath = GetWebTempDirectory + "\" +  bstrTempFileName
  96.     bstrFileName = GetFileName(bstrFilePath)
  97.     
  98.     Set objAttach = objAttachColl.Add(bstrFileName,1,,bstrTempFilePath)
  99.     
  100.     'Create a text file of the same name and close it. This code writes a 0 byte file over the
  101.     'file that was just uploaded.
  102.     Set fs = CreateObject("Scripting.FileSystemObject")
  103.     Set tmp = fs.CreateTextFile(bstrTempFilePath, True)
  104.     tmp.close  
  105.     
  106.     objAttach.Source = bstrFileName
  107.     Set objFields = objAttach.Fields
  108.     objFields.Item(ActMsgPR_DISPLAY_NAME) = bstrFileName 
  109.     objFields.Item(ActMsgPR_ATTACH_MIME_TAG) = bstrMimeType  
  110.         objFields.Item(ActMsgPR_ATTACH_TAG) = "2A864886F714030A04" 
  111.     objFields.Item(ActMsgPR_ATTACH_EXTENSION) = GetFileExt(bstrFileName)
  112.     Set objFields = Nothing
  113.     Set AddAttachment = objAttach
  114. End Function
  115. %>