Outlook 2000 troubles getting SenderEmailType

  • Thread starter Thread starter demausdauth
  • Start date Start date
D

demausdauth

I have a Windows Application that fills a grid on a form getting the
read/unread items from the installed Outlook application. I am using VS 2005
and the Outlook reference is ver 11.00 object model. This form supports
Outlook versions 2000 +

All versions except 2000 are working fine. The error we get is:

System.MissingMemberException: Public member 'SenderEmailType' on type
'MailItem' not found. etc....

This had been working for Outlook 2000 + (thanks very much to Dmitry) then I
had changed it slightly, got busy for a couple of months and now it seems to
be broken. We obviously don't have many customers using Outlook2000 :) .

Here is the code:

Dim oApp As Object = CreateObject("Outlook.Application")
If oApp Is Nothing Then
MessageBox.Show("To utilize Email Inbox, it is required that
MS Outlook be installed on your computer.", "Email Inbox",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Try
End If

Dim sClassComp As Object = "IPM.Note"
Dim clsReadRe As Object = "REPORT.IPM.Note.IPNRN" ' this is the
class of a read receipt
Dim clsDeliveredRe As Object = "REPORT.IPM.Note.DR" ' this is
the class of delivery receipt
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI")
Dim oInbox As Outlook.MAPIFolder =
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Dim oItems As Outlook.Items = oInbox.Items

If Not chkAllItems.Checked Then
oItems = oItems.Restrict("[Unread] = true")
End If

Dim oMsg As Object
For i As Integer = 1 To oItems.Count
getExchange = False
oMsg = oItems.Item(i)

Select Case oMsg.MessageClass.ToString.ToUpper
Case "IPM.NOTE" 'email message

If Not (oMsg.Subject Is Nothing And oMsg.To Is
Nothing And oMsg.SenderName Is Nothing) Then

Dim strFrom As String = ""
drTemp = dtInBox.NewRow

If oMsg.SenderEmailType = "EX" Then
strFrom = oMsg.SenderName
getExchange = True

Else
strFrom = oMsg.SenderName & " " &
oMsg.SenderEmailAddress
End If

drTemp.Item("Subject") = oMsg.Subject
drTemp.Item("From") = strFrom
drTemp.Item("TimeReceived") = oMsg.ReceivedTime
drTemp.Item("Body") = oMsg.Body
drTemp.Item("To") = oMsg.To
drTemp.Item("CC") = oMsg.CC
drTemp.Item("EntryID") = oMsg.EntryID
drTemp.Item("StoreID") = oMsg.Parent.StoreID
drTemp.Item("EX") = getExchange

If oMsg.Attachments.Count > 0 Then
drTemp.Item("Attachments") = 1
Else
drTemp.Item("Attachments") = 0
End If

dtInBox.Rows.Add(drTemp)
End If

Case "REPORT.IPM.NOTE.DR" 'delivery notice
Dim strHappy As String
strHappy = ""


Case "REPORT.IPM.NOTE.IPNRN" 'read receipt
Dim strHappy As String
strHappy = ""


End Select

Next

The main question is why am I now getting an error when I check for the
SenderEmailType?
 
SenderEmailType is a property that was first introduced in Outlook 2003, so
the code will throw an error in previous versions. Make sure that you
reference the .dll of the earliest version of Outlook that you need to
support.

--
Eric Legault - MVP - Outlook
MCDBA, MCTS (Messaging & Collaboration, SharePoint Infrastructure, WSS 3
Application Development, MOSS 2007 Application Development)
Blog: http://blogs.officezealot.com/legault
Try Picture Attachments Wizard for Outlook!
http://www.collaborativeinnovations.ca


demausdauth said:
I have a Windows Application that fills a grid on a form getting the
read/unread items from the installed Outlook application. I am using VS
2005
and the Outlook reference is ver 11.00 object model. This form supports
Outlook versions 2000 +

All versions except 2000 are working fine. The error we get is:

System.MissingMemberException: Public member 'SenderEmailType' on type
'MailItem' not found. etc....

This had been working for Outlook 2000 + (thanks very much to Dmitry) then
I
had changed it slightly, got busy for a couple of months and now it seems
to
be broken. We obviously don't have many customers using Outlook2000 :) .

Here is the code:

Dim oApp As Object = CreateObject("Outlook.Application")
If oApp Is Nothing Then
MessageBox.Show("To utilize Email Inbox, it is required
that
MS Outlook be installed on your computer.", "Email Inbox",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Try
End If

Dim sClassComp As Object = "IPM.Note"
Dim clsReadRe As Object = "REPORT.IPM.Note.IPNRN" ' this is the
class of a read receipt
Dim clsDeliveredRe As Object = "REPORT.IPM.Note.DR" ' this is
the class of delivery receipt
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI")
Dim oInbox As Outlook.MAPIFolder =
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Dim oItems As Outlook.Items = oInbox.Items

If Not chkAllItems.Checked Then
oItems = oItems.Restrict("[Unread] = true")
End If

Dim oMsg As Object
For i As Integer = 1 To oItems.Count
getExchange = False
oMsg = oItems.Item(i)

Select Case oMsg.MessageClass.ToString.ToUpper
Case "IPM.NOTE" 'email message

If Not (oMsg.Subject Is Nothing And oMsg.To Is
Nothing And oMsg.SenderName Is Nothing) Then

Dim strFrom As String = ""
drTemp = dtInBox.NewRow

If oMsg.SenderEmailType = "EX" Then
strFrom = oMsg.SenderName
getExchange = True

Else
strFrom = oMsg.SenderName & " " &
oMsg.SenderEmailAddress
End If

drTemp.Item("Subject") = oMsg.Subject
drTemp.Item("From") = strFrom
drTemp.Item("TimeReceived") = oMsg.ReceivedTime
drTemp.Item("Body") = oMsg.Body
drTemp.Item("To") = oMsg.To
drTemp.Item("CC") = oMsg.CC
drTemp.Item("EntryID") = oMsg.EntryID
drTemp.Item("StoreID") = oMsg.Parent.StoreID
drTemp.Item("EX") = getExchange

If oMsg.Attachments.Count > 0 Then
drTemp.Item("Attachments") = 1
Else
drTemp.Item("Attachments") = 0
End If

dtInBox.Rows.Add(drTemp)
End If

Case "REPORT.IPM.NOTE.DR" 'delivery notice
Dim strHappy As String
strHappy = ""


Case "REPORT.IPM.NOTE.IPNRN" 'read receipt
Dim strHappy As String
strHappy = ""


End Select

Next

The main question is why am I now getting an error when I check for the
SenderEmailType?
 
I believe the only way to confirm that a received e-mail is from an Exchange
server is to either parse the message header and look for "X-MIMEOLE:
Produced By Microsoft Exchange V6.5", or access that property and value via
the DASL name
(http://schemas.microsoft.com/mapi/string/{00020386-0000-0000-C000-000000000046}/x-mimeole).
Both of those methods though would require Redemption
(http://www.dimastr.com), although you can access MAPI properties like this
one with CDO (it's just easier with Redemption).

--
Eric Legault
MVP - Outlook
MCDBA, MCTS (Messaging & Collaboration, SharePoint Infrastructure, MOSS 2007
& WSS 3.0 Application Development)
Collaborative Innovations
-> Try Picture Attachments Wizard For Microsoft Outlook <-
Web: http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault

demausdauth said:
Thanks Eric for responding.

I have since found out that it isn't one of the properties available as
you
say. So now my question becomes -

How can I check to see if a mail item is from an Exchange server or not,
and
have it work for Outlook 2000+ ?

i can check the version of Outlook and run code specific to different
versions, I just don't know what to run for 2000 & 2002 versions to tell
if
it is an Exchange or not.

Eric Legault said:
SenderEmailType is a property that was first introduced in Outlook 2003,
so
the code will throw an error in previous versions. Make sure that you
reference the .dll of the earliest version of Outlook that you need to
support.

--
Eric Legault - MVP - Outlook
MCDBA, MCTS (Messaging & Collaboration, SharePoint Infrastructure, WSS 3
Application Development, MOSS 2007 Application Development)
Blog: http://blogs.officezealot.com/legault
Try Picture Attachments Wizard for Outlook!
http://www.collaborativeinnovations.ca


demausdauth said:
I have a Windows Application that fills a grid on a form getting the
read/unread items from the installed Outlook application. I am using VS
2005
and the Outlook reference is ver 11.00 object model. This form supports
Outlook versions 2000 +

All versions except 2000 are working fine. The error we get is:

System.MissingMemberException: Public member 'SenderEmailType' on type
'MailItem' not found. etc....

This had been working for Outlook 2000 + (thanks very much to Dmitry)
then
I
had changed it slightly, got busy for a couple of months and now it
seems
to
be broken. We obviously don't have many customers using Outlook2000 :)
.

Here is the code:

Dim oApp As Object = CreateObject("Outlook.Application")
If oApp Is Nothing Then
MessageBox.Show("To utilize Email Inbox, it is required
that
MS Outlook be installed on your computer.", "Email Inbox",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Exit Try
End If

Dim sClassComp As Object = "IPM.Note"
Dim clsReadRe As Object = "REPORT.IPM.Note.IPNRN" ' this is
the
class of a read receipt
Dim clsDeliveredRe As Object = "REPORT.IPM.Note.DR" ' this
is
the class of delivery receipt
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI")
Dim oInbox As Outlook.MAPIFolder =
oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Dim oItems As Outlook.Items = oInbox.Items

If Not chkAllItems.Checked Then
oItems = oItems.Restrict("[Unread] = true")
End If

Dim oMsg As Object
For i As Integer = 1 To oItems.Count
getExchange = False
oMsg = oItems.Item(i)

Select Case oMsg.MessageClass.ToString.ToUpper
Case "IPM.NOTE" 'email message

If Not (oMsg.Subject Is Nothing And oMsg.To Is
Nothing And oMsg.SenderName Is Nothing) Then

Dim strFrom As String = ""
drTemp = dtInBox.NewRow

If oMsg.SenderEmailType = "EX" Then
strFrom = oMsg.SenderName
getExchange = True

Else
strFrom = oMsg.SenderName & " " &
oMsg.SenderEmailAddress
End If

drTemp.Item("Subject") = oMsg.Subject
drTemp.Item("From") = strFrom
drTemp.Item("TimeReceived") =
oMsg.ReceivedTime
drTemp.Item("Body") = oMsg.Body
drTemp.Item("To") = oMsg.To
drTemp.Item("CC") = oMsg.CC
drTemp.Item("EntryID") = oMsg.EntryID
drTemp.Item("StoreID") = oMsg.Parent.StoreID
drTemp.Item("EX") = getExchange

If oMsg.Attachments.Count > 0 Then
drTemp.Item("Attachments") = 1
Else
drTemp.Item("Attachments") = 0
End If

dtInBox.Rows.Add(drTemp)
End If

Case "REPORT.IPM.NOTE.DR" 'delivery notice
Dim strHappy As String
strHappy = ""


Case "REPORT.IPM.NOTE.IPNRN" 'read receipt
Dim strHappy As String
strHappy = ""


End Select

Next

The main question is why am I now getting an error when I check for the
SenderEmailType?
 
Back
Top