Sub SaveMyMsg(MyMail As MailItem)
'MVP OShon from VBATools.pl
Dim fso As Object 'FileSystemObject
Dim strID$, strFolderPath$, strSaveName$
Dim olNS As Outlook.NameSpace
Dim oMail As Outlook.MailItem
Dim strSubject As String
strSubject = MyMail.Subject
strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set oMail = olNS.GetItemFromID(strID)
strFolderPath = MakeWholePath("C:\Temp\email")
strSaveName = strSubject
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(strFolderPath & strSaveName) Then
fso.DeleteFile strFolderPath & strSaveName
End If
oMail.SaveAs strFolderPath & strSaveName, OLTXT
Set oMail = Nothing
Set olNS = Nothing
Set fso = Nothing
End Sub
Private Function FileExists(FilePath As String) As Boolean
On Error GoTo blad
FileExists = Len(Dir(FilePath, vbDirectory Or vbHidden Or vbSystem)) > 0
Exit Function
blad:
FileExists = False
End Function
Private Sub MakeWholePath(FileWithPath As String)
Dim x&, PathToMake$
For x = LBound(Split(FileWithPath, "\")) To UBound(Sp
Tak jak w temacie . Skrypt działał dopuki nie dodałem linijek odpowiedzialnych za pobieranie nazwy tematu z maila:
Dim strSubject As String
strSubject = MyMail.Subject