paddysheeran
07-28-2011, 07:04 AM
Hi all,
after a lot of searches round the net for an answer I have not been able to find a full procedure on the code and actions needed to store the email senders full address (e.g. samplename@samplehome.com) in a variable for search and count purposes.
My Code current reads:
Public ReportingYear, ReportingMonth, ReportingMonthNumeric, Date_Month, From_Status As String
Dim objOLMail As Object
Sub SHLNG_Emails()
Dim objOutlook As Object, ns As Object, objFolder, Inbox, objOLMail As Object
Dim EmailCount As Integer
Set ns = GetNamespace("MAPI")
Date_Calculations
Date_Month = ReportingMonthNumeric & " " & ReportingMonth
Set Inbox = ns.Folders("Mailbox - Custom Service Desk G").Folders("Inbox").Folders("Archive").Folders(ReportingYear).Folders(Date_Month)
For Each objOLMail In Inbox.Items
From_Status = objOLMail.SenderEmailAddress
If InStr(objOLMail.SenderEmailAddress, "@Sample1Address.com") > 0 Then
EmailCount = EmailCount + 1
End If
Next
If EmailCount = 0 Then
MsgBox "There were no emails received in this reporting period.", vbInformation, _
"Nothing Found"
Exit Sub
End If
MsgBox "There were " & EmailCount & " emails received in this reporting period.", vbInformation, _
"Emails Found"
End Sub
Instead of the SenderEmailaddress which reads something like /O=EXCHANGE/OU=BTUK01/CN=RECIPIENTS/CN=SUPPLIST I need the full address so I can performe the search:
If InStr(objOLMail.SenderEmailAddress, "@Sample1Address.com") > 0 Then
EmailCount = EmailCount + 1
I believe there is some fuction available to do this but im unsure how to merge this with my code to gain the results I need.
many thanks in advance.
Paddy.
after a lot of searches round the net for an answer I have not been able to find a full procedure on the code and actions needed to store the email senders full address (e.g. samplename@samplehome.com) in a variable for search and count purposes.
My Code current reads:
Public ReportingYear, ReportingMonth, ReportingMonthNumeric, Date_Month, From_Status As String
Dim objOLMail As Object
Sub SHLNG_Emails()
Dim objOutlook As Object, ns As Object, objFolder, Inbox, objOLMail As Object
Dim EmailCount As Integer
Set ns = GetNamespace("MAPI")
Date_Calculations
Date_Month = ReportingMonthNumeric & " " & ReportingMonth
Set Inbox = ns.Folders("Mailbox - Custom Service Desk G").Folders("Inbox").Folders("Archive").Folders(ReportingYear).Folders(Date_Month)
For Each objOLMail In Inbox.Items
From_Status = objOLMail.SenderEmailAddress
If InStr(objOLMail.SenderEmailAddress, "@Sample1Address.com") > 0 Then
EmailCount = EmailCount + 1
End If
Next
If EmailCount = 0 Then
MsgBox "There were no emails received in this reporting period.", vbInformation, _
"Nothing Found"
Exit Sub
End If
MsgBox "There were " & EmailCount & " emails received in this reporting period.", vbInformation, _
"Emails Found"
End Sub
Instead of the SenderEmailaddress which reads something like /O=EXCHANGE/OU=BTUK01/CN=RECIPIENTS/CN=SUPPLIST I need the full address so I can performe the search:
If InStr(objOLMail.SenderEmailAddress, "@Sample1Address.com") > 0 Then
EmailCount = EmailCount + 1
I believe there is some fuction available to do this but im unsure how to merge this with my code to gain the results I need.
many thanks in advance.
Paddy.