|
如何自动保存以邮件发件人地址命名的邮件附件?以前的帖子中有自动保存附件的程序代码,但由于我接受的邮件附件文件名大多数都相同,需要根据邮件发件人地址予以区分: Sub SaveUnreadMail() Dim olApp As New Outlook.Application Dim nmsName As Outlook.NameSpace Dim fldFolder As Outlook.Folder Dim vItem As Object Set nmsName = olApp.GetNamespace("MAPI") Set fldFolder = nmsName.GetDefaultFolder(olFolderInbox) If fldFolder.UnReadItemCount > 0 Then For Each vItem In fldFolder.Items If vItem.UnRead = True Then strname = vItem.Subject strname = Replace(strname, "*", "_") strname = Replace(strname, "\", "_") strname = Replace(strname, "/", "_") strname = Replace(strname, "$", "_") strname = Replace(strname, "%", "_") strname = Replace(strname, "!", "_") strname = Replace(strname, "~", "_") strname = Replace(strname, "(", "_") strname = Replace(strname, ")", "_") strname = Replace(strname, "+", "_") strname = Replace(strname, ":", "_") vItem.SaveAs "C:\" & strname & ".txt", olTXT vItem.UnRead = False End If Next End If End Sub
|
|