i have a script that detachs every attachment and saves it to a local storage.
It's almost like this script from this post.
This works fine. I addapted the script so that a notify message is added to the email body with a link to the local file (file:///...)percepts wrote: ↑2014-09-01 15:03**** Version 2. ****
[...]
Code: Select all
Sub DeleteAttachments(oMessage) ' this routine deletes or quarantines file attachments that have the specified ' FileExtensions. It replaces the functionality of antivirus blocked attachments panel in hmailadmin ' and also has a selectable quarantine option Dim Quarantine ' set to True to Quarantine or False to Delete attachments Quarantine = True Dim QuarantineFolder 'where to store quarantined attachments. This folder must already exist. QuarantineFolder = "c:\path to quarantine folder\" ' trailing slash is required Dim QuarantineFile Dim FileExtensions ' set to the file attachment extensions you want to delete or quarantine FileExtensions = "(bat|cmd|com|cpl|csh|docm|exe|pif|hta|htb|inf|js|jse|lnk|msi|msp|pif|reg|scf|scr|shs|shb|vbe|vbs|wsf|wsh)" ' change anything below here at your own risk. Dim AttachmentDeleteNotify AttachmentDeleteNotify = Empty Dim oAttachment Dim oRegExp Set oRegExp = new RegExp For oAttachment = 0 to oMessage.Attachments.Count-1 ' Test for undesirable attachments with oRegExp .Pattern = "^.*\."& FileExtensions & "$" .IgnoreCase = True .Global = False end with if (oRegExp.test(oMessage.Attachments(oAttachment).Filename)) Then ' Delete Attachment AttachmentDeleteNotify = AttachmentDeleteNotify & oMessage.Attachments(oAttachment).Filename & "~" If (Quarantine) Then QuarantineFile = QuarantineFolder & Left(Right(oMessage.Filename,42),38) _ & "." & oAttachment & "." & oMessage.Attachments(oAttachment).Filename & "." & ".Quarantined" oMessage.Attachments(oAttachment).SaveAs(QuarantineFile) oMessage.Attachments(oAttachment).Delete Else oMessage.Attachments(oAttachment).Delete End If End If Next Set oRegExp = nothing If Not IsEmpty(AttachmentDeleteNotify) then AttachmentDeleteNotify = "The following attachment/s were blocked for delivery by the e-mail server." & "~" _ & "Please contact your system administrator if you have any questions regarding this." & "~" & "~" _ & "Notice ID: " & Left(Right(oMessage.Filename,42),38) & "~" & "~" _ & AttachmentDeleteNotify _ & "~" & "Mail Server Admin" & "~" & "~" Dim htmlNotify htmlNotify = AttachmentDeleteNotify If ( Len(oMessage.Body) <> 0 ) Then AttachmentDeleteNotify = Replace(AttachmentDeleteNotify, "~", VbCrLf) oMessage.Body = oMessage.Body & VbCrLf & VbCrLf & AttachmentDeleteNotify End If If ( Len(oMessage.HTMLBody) <> 0 ) Then htmlNotify = Replace(htmlNotify, "~", ("<br>" & VbCrLf)) oMessage.HTMLBody = Replace(oMessage.HTMLBody, "</body", ("<br><br>" & htmlNotify & "</BODY"), 1, 1, vbTextCompare) End If oMessage.Save End If End Sub
Because i only use thunderbird in my setting... now i want to change the email (body or header?) to insert a thunderbird specific code like this:
Code: Select all
--------------0081oWSEhfxNzrkx1HHTPxlj
Content-Type: application/pdf; name="example.pdf"
Content-Disposition: attachment; filename="example.pdf"
X-Mozilla-External-Attachment-URL: file:///P:/attachments/example.pdf
X-Mozilla-Altered: AttachmentDetached; date="Mon Apr 03 13:35:37 2023"
You deleted an attachment from this message. The original MIME headers for the attachment were:
Content-Type: application/pdf; name="example.pdf"
Content-Disposition: attachment; filename="example.pdf"
Content-Transfer-Encoding: base64
--------------0081oWSEhfxNzrkx1HHTPxlj--
This tells Thunderbird to show a banner at the bottom with a clickable link to the local file Is this possible?