就是版主在7楼回答的下半部分! Sub Savetheattachment() 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'这个可不要,注释掉 '-----保存附件------- For Each att In vItem.Attachments att.SaveAsFile "C:\" & att.FileName '使用shell print打印文档 ' strFile = "C:\" & att.DisplayName '这个注释掉 ' 下一个文档 ' ReturnVal = ShellExecute(0&, "print", strFile, 0&, 0&, 0&)'这个注释掉 Next '------保存附件-------- vItem.UnRead = False End If Next End If Set fldFolder = Nothing Set nmsName = Nothing End Sub |