我想知道是否有人可以帮助我对mAttachmentSaver代码(Microsoft VBA代码,仅保存所选电子邮件中的附件)进行一些更改。我希望附件保护程序仅保存.pdf,.doc和excel文件。这是为了排除各种电子邮件附件,例如邮件本身中的图像。我正在按照我在互联网上找到的以下代码的思路进行思考:FileFilter:="Excel,.xls;.pdf,".
虽然不确定该放在哪里。
另外,我想要这一行:
If lNum > 0 Then
MsgBox CStr(lNum) & " attachment(s) was(were) saved successfully.", vbInformation, "Message from Attachment Saver"
Else
能够显示随机句子,但是我不确定如何执行此操作。例如:
If lNum > 0 Then
MsgBox CStr(lNum) & " attachment(s) was(were) saved successfully. Good job! :)", vbInformation, "Message from Attachment Saver"
MsgBox CStr(lNum) & " attachment(s) was(were) saved successfully. Nice work!", vbInformation, "Message from Attachment Saver"
MsgBox CStr(lNum) & " attachment(s) was(were) saved successfully. You got it!", vbInformation, "Message from Attachment Saver"
MsgBox CStr(lNum) & " attachment(s) was(were) saved successfully. Job done! Time for weekend!", vbInformation, "Message from Attachment Saver"
Else
提前谢谢!链接到代码:https://gallery.technet.microsoft.com/office/Save-attachments-from-5b6bf54b
答案 0 :(得分:1)
Mohit的答案涵盖了过滤部分。这是随机消息部分。
现在与示例一样,它带有4条消息,但是如果要扩展它,则必须更改Int((4 * Rnd) + 1)
。将4更改为更高的值,例如5,然后您将获得5条随机消息。然后还添加一条带有新消息的Case
语句。
If lNum > 0 Then
Dim Message As String
Message = CStr(lNum) & " attachment(s) was(were) saved successfully."
Select Case Int((4 * Rnd) + 1)
Case 1
Message = Message & " Good job! :)"
Case 2
Message = Message & " Nice work!"
Case 3
Message = Message & " You got it!"
Case 4
Message = Message & " Job done! Time for weekend!"
End Select
MsgBox Message, vbInformation, "Message from Attachment Saver"
答案 1 :(得分:0)