473,224 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

Waht is the fastest/bets? Outlook Object/CDO/Redemption/...?

Hi,

I'm using a thight integration with Outlook 2003 (with an Exchange server)
in my VB.NET (2005) application.
Until now I'm using the Outlook Object Model, but it appears to be very
slow, and has some problems:
- doing a Move changes the ReceivedTime of the MailItem
- I can't use RichText in the MailItem.Body (only allows plain text or HTML)
- some other stuff like having to use small 'tricks' to show the default
signature in an email
- ...

So I'm looking to other ways to have an interactions with Outlook.
What I basicly need to do is:
- Move the currently selected mail to a specific folder, and write the data
of it to a database (subject, entryid, sender, recipients, attachments, ..)
- Create a new mail with a specific text, receiver, subject, attachements,
and once it is send move it to a specific folder and write the same data to
the database

These things actually do work, but especially the first one takes too much
time: on some clients more than 10 seconds!!
Is their a way to speed things up? using CDO or Redemption or ...? What are
the pros and cons of each way? Can they do what I need?

Any help our hints would be really aprpeciated!

Thanks a lot in advance,

Pieter
I did it now like this:

Public Function AddDocMails(ByVal DocList As Generic.List(Of clsDoc)) As
String
Dim oApp As Outlook.Application
Dim oExp As Outlook.Explorer
Dim oSel As Outlook.Selection ' You need a selection object for
getting the selection.
Dim oFolder As Outlook.MAPIFolder
Dim oItem As Outlook.MailItem

Dim intGood As Integer = 0
Dim intTotaal As Integer = 0

Try
oApp = New Outlook.Application
oExp = oApp.ActiveExplorer ' Get the ActiveExplorer.
oSel = oExp.Selection ' Get the selection.

Dim intX As Integer
Dim clsMail As clsDocMail
oFolder = oExp.CurrentFolder
intTotaal = oSel.Count

For intX = 1 To (oSel.Count)
Try

If oSel.Item(intX).Class = Outlook.OlObjectClass.olMail
Then
oItem = oSel.Item(intX)
clsMail = New clsDocMail(oItem, oFolder)
'save it!
clsMail.Save()
End If
Catch ex As Exception
ErrorMessage(ex, "Inner AddDocMails")
End Try
Next
Catch ex As Exception
ErrorMessage(ex)
End Try

oItem = Nothing
oFolder = Nothing
oSel = Nothing
oExp = Nothing
oApp = Nothing

Return strF
End Function
Public Sub New(ByVal ItemOutlook As Object, ByVal FolderOutlook As
Object)
Me.New()
Me.oItem = ItemOutlook
Me.oFolder = FolderOutlook

Me.GetMailInfo()
End Sub
Public Function GetMailInfo(Optional ByVal blnMove As Boolean = True) As
Boolean
Dim blnOk As Boolean = True

Try
If blnMove Then
Try
If (oFolder.StoreID <>
clsDocShared.GlobalDoc.MyOutlookFolder.StoreID) Or (oFolder.EntryID <>
clsDocShared.GlobalDoc.MyOutlookFolder.EntryID) Then
'Move it to the right folder: StoreID
oItem =
oItem.Move(clsDocShared.GlobalDoc.MyOutlookFolder)
End If
Catch ex As Exception
blnOk = False
Return blnOk
Exit Function
End Try
End If

'FolderID
Me.FolderID = clsDocShared.GlobalDoc.MyOutlookFolderID
'FileLink = MailLink = EntryID
Me.FileLink = oItem.EntryID

'From and to etc...
Me.MailFrom = oItem.SenderName
If oItem.To IsNot Nothing Then
Me.MailTo = oItem.To
End If

If oItem.CC IsNot Nothing Then
Me.MailCC = oItem.CC
End If
If oItem.BCC IsNot Nothing Then
If Me.MailCC Is Nothing Then
Me.MailCC = ""
End If
If Me.MailCC.Length > 0 Then
Me.MailCC = Me.MailCC & ", "
End If
Me.MailCC = Me.MailCC & oItem.BCC
End If
If oItem.Subject IsNot Nothing Then
Me.MailSubject = oItem.Subject
End If

Me.MailDate = oItem.ReceivedTime
Me.AddDate = Me.MailDate

Dim intA As Integer
'premier Type identification
'?oitem.MessageClass =
-> FAX
'?oitem.MessageClass =
-> MAIL
Dim strI As String
If oItem.MessageClass = "IPM.FAX" Then
'received
strI = "FAX"
Else
strI = "MAIL"
End If
If (strI = "MAIL") And (oItem.Recipients.Count > 0) Then
If oItem.Recipients.Item(1).AddressEntry.Type.ToStrin g =
"FAX" Then
'send
strI = "FAX"
ElseIf oItem.SenderName = "FAXINSDX" Then
'een fax wordt soms doorgemaild naar iemand!!!
strI = "FAX"
End If
End If
Me.MailType = strI

If oItem.Attachments.Count > 0 Then
Me.MailType = Me.MailType & ".ATTACHMENT"
Me.Attachments = ""
For intA = 1 To oItem.Attachments.Count
If intA > 1 Then
Me.Attachments = Me.Attachments & ", "
End If
Me.Attachments = Me.Attachments &
oItem.Attachments.Item(intA).FileName.ToString
Next
End If

If oItem.FlagStatus = Outlook.OlFlagStatus.olFlagMarked Then
Me.Flag = "1"
ElseIf oItem.FlagStatus = Outlook.OlFlagStatus.olFlagComplete
Then
Me.Flag = "2"
End If
If oItem.Importance = Outlook.OlImportance.olImportanceHigh Then
Me.Flag = "1"
End If
Catch ex As Exception
blnOk = False
ErrorMessage(ex, "GetMailInfoDebug: " & strStatus)
End Try

Return blnOk
End Function

Feb 1 '06 #1
2 2423
Use CDO/Redemption if you need to work with large sets of items, especially
looping through collections. Use Redemption for bypassing the Object Model
Guard and to use some MAPI stuff, profile management and other functions not
handled by CDO. Stick with the OOM if you are primarily working with UI
related elements of Outlook items.

There's been other discussions lately around ReceivedTime changing; google
this group to see some threads.

To modify Rich Text, use the Word Object Model if Word is being used as the
editor, or the SafeInspector object with Redemption.

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
"Pieter" wrote:
Hi,

I'm using a thight integration with Outlook 2003 (with an Exchange server)
in my VB.NET (2005) application.
Until now I'm using the Outlook Object Model, but it appears to be very
slow, and has some problems:
- doing a Move changes the ReceivedTime of the MailItem
- I can't use RichText in the MailItem.Body (only allows plain text or HTML)
- some other stuff like having to use small 'tricks' to show the default
signature in an email
- ...

So I'm looking to other ways to have an interactions with Outlook.
What I basicly need to do is:
- Move the currently selected mail to a specific folder, and write the data
of it to a database (subject, entryid, sender, recipients, attachments, ..)
- Create a new mail with a specific text, receiver, subject, attachements,
and once it is send move it to a specific folder and write the same data to
the database

These things actually do work, but especially the first one takes too much
time: on some clients more than 10 seconds!!
Is their a way to speed things up? using CDO or Redemption or ...? What are
the pros and cons of each way? Can they do what I need?

Any help our hints would be really aprpeciated!

Thanks a lot in advance,

Pieter
I did it now like this:

Public Function AddDocMails(ByVal DocList As Generic.List(Of clsDoc)) As
String
Dim oApp As Outlook.Application
Dim oExp As Outlook.Explorer
Dim oSel As Outlook.Selection ' You need a selection object for
getting the selection.
Dim oFolder As Outlook.MAPIFolder
Dim oItem As Outlook.MailItem

Dim intGood As Integer = 0
Dim intTotaal As Integer = 0

Try
oApp = New Outlook.Application
oExp = oApp.ActiveExplorer ' Get the ActiveExplorer.
oSel = oExp.Selection ' Get the selection.

Dim intX As Integer
Dim clsMail As clsDocMail
oFolder = oExp.CurrentFolder
intTotaal = oSel.Count

For intX = 1 To (oSel.Count)
Try

If oSel.Item(intX).Class = Outlook.OlObjectClass.olMail
Then
oItem = oSel.Item(intX)
clsMail = New clsDocMail(oItem, oFolder)
'save it!
clsMail.Save()
End If
Catch ex As Exception
ErrorMessage(ex, "Inner AddDocMails")
End Try
Next
Catch ex As Exception
ErrorMessage(ex)
End Try

oItem = Nothing
oFolder = Nothing
oSel = Nothing
oExp = Nothing
oApp = Nothing

Return strF
End Function
Public Sub New(ByVal ItemOutlook As Object, ByVal FolderOutlook As
Object)
Me.New()
Me.oItem = ItemOutlook
Me.oFolder = FolderOutlook

Me.GetMailInfo()
End Sub
Public Function GetMailInfo(Optional ByVal blnMove As Boolean = True) As
Boolean
Dim blnOk As Boolean = True

Try
If blnMove Then
Try
If (oFolder.StoreID <>
clsDocShared.GlobalDoc.MyOutlookFolder.StoreID) Or (oFolder.EntryID <>
clsDocShared.GlobalDoc.MyOutlookFolder.EntryID) Then
'Move it to the right folder: StoreID
oItem =
oItem.Move(clsDocShared.GlobalDoc.MyOutlookFolder)
End If
Catch ex As Exception
blnOk = False
Return blnOk
Exit Function
End Try
End If

'FolderID
Me.FolderID = clsDocShared.GlobalDoc.MyOutlookFolderID
'FileLink = MailLink = EntryID
Me.FileLink = oItem.EntryID

'From and to etc...
Me.MailFrom = oItem.SenderName
If oItem.To IsNot Nothing Then
Me.MailTo = oItem.To
End If

If oItem.CC IsNot Nothing Then
Me.MailCC = oItem.CC
End If
If oItem.BCC IsNot Nothing Then
If Me.MailCC Is Nothing Then
Me.MailCC = ""
End If
If Me.MailCC.Length > 0 Then
Me.MailCC = Me.MailCC & ", "
End If
Me.MailCC = Me.MailCC & oItem.BCC
End If
If oItem.Subject IsNot Nothing Then
Me.MailSubject = oItem.Subject
End If

Me.MailDate = oItem.ReceivedTime
Me.AddDate = Me.MailDate

Dim intA As Integer
'premier Type identification
'?oitem.MessageClass =
-> FAX
'?oitem.MessageClass =
-> MAIL
Dim strI As String
If oItem.MessageClass = "IPM.FAX" Then
'received
strI = "FAX"
Else
strI = "MAIL"
End If
If (strI = "MAIL") And (oItem.Recipients.Count > 0) Then
If oItem.Recipients.Item(1).AddressEntry.Type.ToStrin g =
"FAX" Then
'send
strI = "FAX"
ElseIf oItem.SenderName = "FAXINSDX" Then
'een fax wordt soms doorgemaild naar iemand!!!
strI = "FAX"
End If
End If
Me.MailType = strI

If oItem.Attachments.Count > 0 Then
Me.MailType = Me.MailType & ".ATTACHMENT"
Me.Attachments = ""
For intA = 1 To oItem.Attachments.Count
If intA > 1 Then
Me.Attachments = Me.Attachments & ", "
End If
Me.Attachments = Me.Attachments &
oItem.Attachments.Item(intA).FileName.ToString
Next
End If

If oItem.FlagStatus = Outlook.OlFlagStatus.olFlagMarked Then
Me.Flag = "1"
ElseIf oItem.FlagStatus = Outlook.OlFlagStatus.olFlagComplete
Then
Me.Flag = "2"
End If
If oItem.Importance = Outlook.OlImportance.olImportanceHigh Then
Me.Flag = "1"
End If
Catch ex As Exception
blnOk = False
ErrorMessage(ex, "GetMailInfoDebug: " & strStatus)
End Try

Return blnOk
End Function

Feb 1 '06 #2
Ok, thanks a lot!

"Eric Legault [MVP - Outlook]" <el*********@REMOVEZZZmvps.org> wrote in
message news:26**********************************@microsof t.com...
Use CDO/Redemption if you need to work with large sets of items,
especially
looping through collections. Use Redemption for bypassing the Object
Model
Guard and to use some MAPI stuff, profile management and other functions
not
handled by CDO. Stick with the OOM if you are primarily working with UI
related elements of Outlook items.

There's been other discussions lately around ReceivedTime changing; google
this group to see some threads.

To modify Rich Text, use the Word Object Model if Word is being used as
the
editor, or the SafeInspector object with Redemption.

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
"Pieter" wrote:
Hi,

I'm using a thight integration with Outlook 2003 (with an Exchange
server)
in my VB.NET (2005) application.
Until now I'm using the Outlook Object Model, but it appears to be very
slow, and has some problems:
- doing a Move changes the ReceivedTime of the MailItem
- I can't use RichText in the MailItem.Body (only allows plain text or
HTML)
- some other stuff like having to use small 'tricks' to show the default
signature in an email
- ...

So I'm looking to other ways to have an interactions with Outlook.
What I basicly need to do is:
- Move the currently selected mail to a specific folder, and write the
data
of it to a database (subject, entryid, sender, recipients, attachments,
..)
- Create a new mail with a specific text, receiver, subject,
attachements,
and once it is send move it to a specific folder and write the same data
to
the database

These things actually do work, but especially the first one takes too
much
time: on some clients more than 10 seconds!!
Is their a way to speed things up? using CDO or Redemption or ...? What
are
the pros and cons of each way? Can they do what I need?

Any help our hints would be really aprpeciated!

Thanks a lot in advance,

Pieter
I did it now like this:

Public Function AddDocMails(ByVal DocList As Generic.List(Of clsDoc)) As
String
Dim oApp As Outlook.Application
Dim oExp As Outlook.Explorer
Dim oSel As Outlook.Selection ' You need a selection object for
getting the selection.
Dim oFolder As Outlook.MAPIFolder
Dim oItem As Outlook.MailItem

Dim intGood As Integer = 0
Dim intTotaal As Integer = 0

Try
oApp = New Outlook.Application
oExp = oApp.ActiveExplorer ' Get the ActiveExplorer.
oSel = oExp.Selection ' Get the selection.

Dim intX As Integer
Dim clsMail As clsDocMail
oFolder = oExp.CurrentFolder
intTotaal = oSel.Count

For intX = 1 To (oSel.Count)
Try

If oSel.Item(intX).Class =
Outlook.OlObjectClass.olMail
Then
oItem = oSel.Item(intX)
clsMail = New clsDocMail(oItem, oFolder)
'save it!
clsMail.Save()
End If
Catch ex As Exception
ErrorMessage(ex, "Inner AddDocMails")
End Try
Next
Catch ex As Exception
ErrorMessage(ex)
End Try

oItem = Nothing
oFolder = Nothing
oSel = Nothing
oExp = Nothing
oApp = Nothing

Return strF
End Function
Public Sub New(ByVal ItemOutlook As Object, ByVal FolderOutlook As
Object)
Me.New()
Me.oItem = ItemOutlook
Me.oFolder = FolderOutlook

Me.GetMailInfo()
End Sub
Public Function GetMailInfo(Optional ByVal blnMove As Boolean = True)
As
Boolean
Dim blnOk As Boolean = True

Try
If blnMove Then
Try
If (oFolder.StoreID <>
clsDocShared.GlobalDoc.MyOutlookFolder.StoreID) Or (oFolder.EntryID <>
clsDocShared.GlobalDoc.MyOutlookFolder.EntryID) Then
'Move it to the right folder: StoreID
oItem =
oItem.Move(clsDocShared.GlobalDoc.MyOutlookFolder)
End If
Catch ex As Exception
blnOk = False
Return blnOk
Exit Function
End Try
End If

'FolderID
Me.FolderID = clsDocShared.GlobalDoc.MyOutlookFolderID
'FileLink = MailLink = EntryID
Me.FileLink = oItem.EntryID

'From and to etc...
Me.MailFrom = oItem.SenderName
If oItem.To IsNot Nothing Then
Me.MailTo = oItem.To
End If

If oItem.CC IsNot Nothing Then
Me.MailCC = oItem.CC
End If
If oItem.BCC IsNot Nothing Then
If Me.MailCC Is Nothing Then
Me.MailCC = ""
End If
If Me.MailCC.Length > 0 Then
Me.MailCC = Me.MailCC & ", "
End If
Me.MailCC = Me.MailCC & oItem.BCC
End If
If oItem.Subject IsNot Nothing Then
Me.MailSubject = oItem.Subject
End If

Me.MailDate = oItem.ReceivedTime
Me.AddDate = Me.MailDate

Dim intA As Integer
'premier Type identification
'?oitem.MessageClass =
-> FAX
'?oitem.MessageClass =
-> MAIL
Dim strI As String
If oItem.MessageClass = "IPM.FAX" Then
'received
strI = "FAX"
Else
strI = "MAIL"
End If
If (strI = "MAIL") And (oItem.Recipients.Count > 0) Then
If oItem.Recipients.Item(1).AddressEntry.Type.ToStrin g =
"FAX" Then
'send
strI = "FAX"
ElseIf oItem.SenderName = "FAXINSDX" Then
'een fax wordt soms doorgemaild naar iemand!!!
strI = "FAX"
End If
End If
Me.MailType = strI

If oItem.Attachments.Count > 0 Then
Me.MailType = Me.MailType & ".ATTACHMENT"
Me.Attachments = ""
For intA = 1 To oItem.Attachments.Count
If intA > 1 Then
Me.Attachments = Me.Attachments & ", "
End If
Me.Attachments = Me.Attachments &
oItem.Attachments.Item(intA).FileName.ToString
Next
End If

If oItem.FlagStatus = Outlook.OlFlagStatus.olFlagMarked Then
Me.Flag = "1"
ElseIf oItem.FlagStatus = Outlook.OlFlagStatus.olFlagComplete
Then
Me.Flag = "2"
End If
If oItem.Importance = Outlook.OlImportance.olImportanceHigh
Then
Me.Flag = "1"
End If
Catch ex As Exception
blnOk = False
ErrorMessage(ex, "GetMailInfoDebug: " & strStatus)
End Try

Return blnOk
End Function

Feb 2 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Anushya | last post by:
Hi All This is the error i am getting when i try to install my addin in some other machine and works fine in development machine. I checked the ..net framework version it is 1.1 in developement...
7
by: Anushya | last post by:
Hi How to get the id of a name in contact items in outlook. How to do it thru redemption in .net?? i tried the code below. but it shows the error. pls have a look at the code ...
4
by: John | last post by:
Hi Does anyone have a vb.net example of how to use redemption to send mail through outlook? Many Thanks Regards
9
by: John | last post by:
Hi Is it possible to write vb.net code around outlook 2000 dlls and then use the code on ol2002 machines to send emails and bypass ol 2002 email block? Thanks Regards
8
by: John | last post by:
Hi I am using the latest redemption. I am using the below code in vb.net to send mail in html format. The problem is that text does not get sent as html and html tags appear as they are in the...
2
by: Pieter | last post by:
Hi, I'm using a thight integration with Outlook 2003 (with an Exchange server) in my VB.NET (2005) application. Until now I'm using the Outlook Object Model, but it appears to be very slow, and...
4
by: omrivm | last post by:
Hi, I have a problem with Outlook Redemption, every time I'm trying to create a new RDOAddressBook: Redemption.RDOAddressBook AB = new RDOAddressBook(); I get: "Retrieving the COM class factory...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.