加密何时将PDF连接到Outlook Mail

发布于 2025-01-29 00:33:35 字数 77 浏览 3 评论 0原文

每当将带有PDF扩展的附件添加到Outlook VBA邮件中时,我都想加密。

有没有办法写这样的宏?

谢谢你吗?

I want to encrypt whenever an attachment with PDF extension is added to mail with Outlook vba.

Is there a way to write such a macro?

Thanky you?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼眸里的那抹悲凉 2025-02-05 00:33:35

您可以处理 mailitem.AttachmentAddd 活动当将附件添加到Outlook项目中时,这将被触发。因此,您可以检查附加文件 - 添加到项目的附件作为参数传递,并在需要时对其进行加密。例如:

Public WithEvents newItem As Outlook.MailItem 
 
Private Sub newItem_AttachmentAdd(ByVal newAttachment As Attachment)
 If newAttachment.Type = olByValue Then 
   newItem.Save 
   If newItem.Size > 500000 Then 
     MsgBox "Warning: Item size is now " & newItem.Size & " bytes." 
   End If 
 End If 
End Sub 
 
Public Sub TestAttachAdd() 
 Dim atts As Outlook.Attachments 
 Dim newAttachment As Outlook.Attachment 
 
 Set newItem = Application.CreateItem(olMailItem) 
 newItem.Subject = "Test attachment" 
 Set atts = newItem.Attachments 
 Set newAttachment = atts.Add("C:\Test.txt", olByValue) 
End Sub

请注意,您可以在磁盘上找到缓存的文件。您可以在Windows注册表中找到实际路径:

”

You can handle the MailItem.AttachmentAdd event which is fired when an attachment has been added to an Outlook item. So, you could check the attached file - the Attachment that was added to the item is passed as a parameter and encrypt it if required. For example:

Public WithEvents newItem As Outlook.MailItem 
 
Private Sub newItem_AttachmentAdd(ByVal newAttachment As Attachment)
 If newAttachment.Type = olByValue Then 
   newItem.Save 
   If newItem.Size > 500000 Then 
     MsgBox "Warning: Item size is now " & newItem.Size & " bytes." 
   End If 
 End If 
End Sub 
 
Public Sub TestAttachAdd() 
 Dim atts As Outlook.Attachments 
 Dim newAttachment As Outlook.Attachment 
 
 Set newItem = Application.CreateItem(olMailItem) 
 newItem.Subject = "Test attachment" 
 Set atts = newItem.Attachments 
 Set newAttachment = atts.Add("C:\Test.txt", olByValue) 
End Sub

Note, you can find the cached file on disk. You can find the actual path in the windows registry:

Outlook cached folder path in Windows registry

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文