Code to Download an Email Attachment
ASP code to return an email attachment.
<%
' This ASP will return an email's Nth attachment.
' The 1st attachment is at index 0.
attachIdx = 0
' This is the filename of the .eml on the ASP server.
emlFilename = "testEmail.eml"
' An email can be loaded into an email object from memory
' by calling SetFromMimeText, or from a file by calling
' LoadEml.
' Create a MailMan object first for the purpose
' of unlocking the component. (Only one is necessary)
set mailman = Server.CreateObject("Chilkat_9_5_0.MailMan")
mailman.UnlockComponent "anything for 30-day trial"
set email = Server.CreateObject("Chilkat_9_5_0.Email")
' Load an email containing attachments.
'
success = email.LoadEml(Server.MapPath(emlFilename))
If (success <> 1) Then
Response.Write email.LastErrorText & "<br>"
End If
'
Response.ContentType = email.GetAttachmentContentType(attachIdx)
Response.BinaryWrite email.GetAttachmentData(attachIdx)
%>
|