Sub SetStatus()
Dim OutApp As Object ' Outlook.Application
Dim NmSpace As Object 'Outlook.NameSpace
Dim Inbox As Object ' Outlook.MAPIFolder
Dim MItem As Object ' Outlook.MailItem
Dim MySubFolder As Object
Dim i As Long
Dim Response As String
Dim BodyArray() As Variant
Dim EmailAddress As String
Dim Ebody As Variant
Dim Ewords As Variant
Dim Status As String
Dim Cell As Range
Dim ProcessedFolder As Object
Dim MatchFound As String
Dim countnoemail As Integer
Dim emaillist As Variant
Dim el As Integer
Set OutApp = CreateObject("Outlook.Application")
Set NmSpace = OutApp.GetNamespace("MAPI")
Set Inbox = NmSpace.GetDefaultFolder(6) 'olFolderInbox
Set MySubFolder = Inbox.Folders("test") ' Note Case Sensitive!
Set ProcessedFolder = Inbox.Folders("processed") ' Note Case Sensitive!
emaillist = ""
el = 0
'****************************************************************
' This macro will look in the body of each email and extract
' the email addresses contained within them to cross reference
' them with the email addresses in excle and will set the status
' according to the subject email. March 4 2011
'****************************************************************
MsgBox MySubFolder.Items.count ' Debugging Only
For Each MItem In MySubFolder.Items ' Starts with first email recieved
Select Case True
Case Left(MItem.Subject, 13) = "Undeliverable": Status = "Undeliverable"
Case Left(MItem.Subject, 4) = "Read": Status = "Read"
Case Left(MItem.Subject, 8) = "Not Read": Status = "Deleted"
Case InStr(MItem.Subject, "(Failure)"): Status = "failed"
Case InStr(MItem.Subject, "(Delay)"): Status = "Delayed"
Case UCase(Left(MItem.Subject, 3)) = "RE:": Status = "Replied"
Case InStr(MItem.Subject, 14) = "Returned mail:": Status = "Invalid Email"
Case Else: Status = "Other"
End Select
MsgBox MItem.SenderEmailAddress
' Now I need to Find all of the email adresses within the email and delete duplicated ones, If any.
If InStr(MItem.body, "@") Then ' If MItem.body contains an @ character
'Assign each word in the body of the email to Ewords
Ewords = Split(MItem.body) ' Split each word in MItem.body and assign it to the Ewords variable
For i = LBound(Ewords) To UBound(Ewords) ' sets the for i loop to the number of split in MItem
If InStr(Ewords(i), "@") Then 'Found the string that contains an email address
'clean the email address
Call EmailAddresCleanup(Ewords(i))
'compare current email with the array
'if it doesn't exist include it and put the status
'if it exit move on
'keep the list of emails until the end of the sub
Else
End If
Next i
MsgBox MItem
Else
' Take the email address from the From field
End If
Next MItem ' Goes to next email
GoTo cleanup ' Cleans all of the variables
cleanup:
Set MItem = Nothing
Set Inbox = Nothing
Set NmSpace = Nothing
Set OutApp = Nothing
Set MySubFolder = Nothing
End Sub
If MItem.MessageClass = "IPM.Note" Then
' it's an email
ElseIf MItem.MessageClass = "IPM.Report" Then
' it's a read receipt
Endif
;2660284 said:Hi,
It's been a few weeks now and I've tried everything, with the exception of the one way it would work .
The my knowledge, there isn't a way of reading the senders email address from a read receipt!
So I will need to find a way to link the read receipt with the original email sent and extract the email from the original person i sent it to. In a way that isn't to bad since I had situations where someone else opened the email! Perhaps, their server automatically forward it.
I will post a new question as i couldn't find how to "link" the two either?