目前,我正在嘗試處理從Outlook收到的每封電子郵件的主題行。所有主題行都列在F列。我希望顯示電子郵件的所有主題行(重複將被刪除,並且每個會話只保留一行 - 帶有RE或FW的郵件已被刪除這些)。新的工作表將包含收件箱中的所有主題行(刪除重複項後只會執行一次)。處理來自Outlook的每封電子郵件的主題行
代碼:
For Each oItem In objSourceFolder.Items
ThisWorkbook.Worksheets("Test 1 Mails").Range("A" & contor).Value = oItem.SentOn
ThisWorkbook.Worksheets("Test 1 Mails").Range("B" & contor).Value = oItem.CreationTime
ThisWorkbook.Worksheets("Test 1 Mails").Range("C" & contor).Value = oItem.ReceivedTime
ThisWorkbook.Worksheets("Test 1 Mails").Range("D" & contor).Value = oItem.SenderName
ThisWorkbook.Worksheets("Test 1 Mails").Range("E" & contor).Value = oItem.SenderEmailAddress
If (Left(oItem.Subject, 4) = "FW: ") Or (Left(oItem.Subject, 4) = "Fw: ") Or (Left(oItem.Subject, 4) = "RE: ") Or (Left(oItem.Subject, 4) = "Re: ") Then
oItem.Subject = Mid(oItem.Subject, 5)
oItem.Save
ThisWorkbook.Worksheets("Test 1 Mails").Range("F" & contor).Value = oItem.Subject
ThisWorkbook.Worksheets("Outlook report").Range("B" & contor).Value = oItem.Subject
Else
If Left(oItem.Subject, 5) = "FWD: " Then
oItem.Subject = Mid(oItem.Subject, 6)
ThisWorkbook.Worksheets("Test 1 Mails").Range("B" & contor).Value = oItem.Subject
ThisWorkbook.Worksheets("Outlook report").Range("B" & contor).Value = oItem.Subject
oItem.Save
End If
End If
那麼,什麼是你的問題?你沒有問過。請閱讀[問]。尋求調試幫助的問題(「*爲什麼這個代碼不工作?」)必須包含所需的行爲,特定的問題或錯誤以及在問題本身中重現問題所需的最短代碼。沒有**明確問題陳述**的問題對其他讀者沒有用處。請參閱:如何創建[mcve]。 –
'1'你面臨什麼問題? '2'爲什麼你要更改Outlook主題行?爲什麼不把它存儲在一個變量中,清理它然後寫入excel文件? –
@ georgian1990,我應該在最初回答之前提出這個問題。你有工作表中的所有電子郵件信息嗎?你的問題是從另一種語言翻譯的嗎? – jsotola