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(ByV al DocList As Generic.List(Of clsDoc)) As
String
Dim oApp As Outlook.Applica tion
Dim oExp As Outlook.Explore r
Dim oSel As Outlook.Selecti on ' You need a selection object for
getting the selection.
Dim oFolder As Outlook.MAPIFol der
Dim oItem As Outlook.MailIte m
Dim intGood As Integer = 0
Dim intTotaal As Integer = 0
Try
oApp = New Outlook.Applica tion
oExp = oApp.ActiveExpl orer ' Get the ActiveExplorer.
oSel = oExp.Selection ' Get the selection.
Dim intX As Integer
Dim clsMail As clsDocMail
oFolder = oExp.CurrentFol der
intTotaal = oSel.Count
For intX = 1 To (oSel.Count)
Try
If oSel.Item(intX) .Class = Outlook.OlObjec tClass.olMail
Then
oItem = oSel.Item(intX)
clsMail = New clsDocMail(oIte m, 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(Opt ional ByVal blnMove As Boolean = True) As
Boolean
Dim blnOk As Boolean = True
Try
If blnMove Then
Try
If (oFolder.StoreI D <>
clsDocShared.Gl obalDoc.MyOutlo okFolder.StoreI D) Or (oFolder.EntryI D <>
clsDocShared.Gl obalDoc.MyOutlo okFolder.EntryI D) Then
'Move it to the right folder: StoreID
oItem =
oItem.Move(clsD ocShared.Global Doc.MyOutlookFo lder)
End If
Catch ex As Exception
blnOk = False
Return blnOk
Exit Function
End Try
End If
'FolderID
Me.FolderID = clsDocShared.Gl obalDoc.MyOutlo okFolderID
'FileLink = MailLink = EntryID
Me.FileLink = oItem.EntryID
'From and to etc...
Me.MailFrom = oItem.SenderNam e
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.Lengt h > 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.ReceivedT ime
Me.AddDate = Me.MailDate
Dim intA As Integer
'premier Type identification
'?oitem.Message Class =
-> FAX
'?oitem.Message Class =
-> MAIL
Dim strI As String
If oItem.MessageCl ass = "IPM.FAX" Then
'received
strI = "FAX"
Else
strI = "MAIL"
End If
If (strI = "MAIL") And (oItem.Recipien ts.Count > 0) Then
If oItem.Recipient s.Item(1).Addre ssEntry.Type.To String =
"FAX" Then
'send
strI = "FAX"
ElseIf oItem.SenderNam e = "FAXINSDX" Then
'een fax wordt soms doorgemaild naar iemand!!!
strI = "FAX"
End If
End If
Me.MailType = strI
If oItem.Attachmen ts.Count > 0 Then
Me.MailType = Me.MailType & ".ATTACHMEN T"
Me.Attachments = ""
For intA = 1 To oItem.Attachmen ts.Count
If intA > 1 Then
Me.Attachments = Me.Attachments & ", "
End If
Me.Attachments = Me.Attachments &
oItem.Attachmen ts.Item(intA).F ileName.ToStrin g
Next
End If
If oItem.FlagStatu s = Outlook.OlFlagS tatus.olFlagMar ked Then
Me.Flag = "1"
ElseIf oItem.FlagStatu s = Outlook.OlFlagS tatus.olFlagCom plete
Then
Me.Flag = "2"
End If
If oItem.Importanc e = Outlook.OlImpor tance.olImporta nceHigh Then
Me.Flag = "1"
End If
Catch ex As Exception
blnOk = False
ErrorMessage(ex , "GetMailInfoDeb ug: " & strStatus)
End Try
Return blnOk
End Function 2 2445
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(ByV al DocList As Generic.List(Of clsDoc)) As String Dim oApp As Outlook.Applica tion Dim oExp As Outlook.Explore r Dim oSel As Outlook.Selecti on ' You need a selection object for getting the selection. Dim oFolder As Outlook.MAPIFol der Dim oItem As Outlook.MailIte m
Dim intGood As Integer = 0 Dim intTotaal As Integer = 0
Try oApp = New Outlook.Applica tion oExp = oApp.ActiveExpl orer ' Get the ActiveExplorer. oSel = oExp.Selection ' Get the selection.
Dim intX As Integer Dim clsMail As clsDocMail oFolder = oExp.CurrentFol der intTotaal = oSel.Count
For intX = 1 To (oSel.Count) Try
If oSel.Item(intX) .Class = Outlook.OlObjec tClass.olMail Then oItem = oSel.Item(intX) clsMail = New clsDocMail(oIte m, 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(Opt ional ByVal blnMove As Boolean = True) As Boolean Dim blnOk As Boolean = True
Try If blnMove Then Try If (oFolder.StoreI D <> clsDocShared.Gl obalDoc.MyOutlo okFolder.StoreI D) Or (oFolder.EntryI D <> clsDocShared.Gl obalDoc.MyOutlo okFolder.EntryI D) Then 'Move it to the right folder: StoreID oItem = oItem.Move(clsD ocShared.Global Doc.MyOutlookFo lder) End If Catch ex As Exception blnOk = False Return blnOk Exit Function End Try End If
'FolderID Me.FolderID = clsDocShared.Gl obalDoc.MyOutlo okFolderID 'FileLink = MailLink = EntryID Me.FileLink = oItem.EntryID
'From and to etc... Me.MailFrom = oItem.SenderNam e 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.Lengt h > 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.ReceivedT ime Me.AddDate = Me.MailDate
Dim intA As Integer 'premier Type identification '?oitem.Message Class = -> FAX '?oitem.Message Class = -> MAIL Dim strI As String If oItem.MessageCl ass = "IPM.FAX" Then 'received strI = "FAX" Else strI = "MAIL" End If If (strI = "MAIL") And (oItem.Recipien ts.Count > 0) Then If oItem.Recipient s.Item(1).Addre ssEntry.Type.To String = "FAX" Then 'send strI = "FAX" ElseIf oItem.SenderNam e = "FAXINSDX" Then 'een fax wordt soms doorgemaild naar iemand!!! strI = "FAX" End If End If Me.MailType = strI
If oItem.Attachmen ts.Count > 0 Then Me.MailType = Me.MailType & ".ATTACHMEN T" Me.Attachments = "" For intA = 1 To oItem.Attachmen ts.Count If intA > 1 Then Me.Attachments = Me.Attachments & ", " End If Me.Attachments = Me.Attachments & oItem.Attachmen ts.Item(intA).F ileName.ToStrin g Next End If
If oItem.FlagStatu s = Outlook.OlFlagS tatus.olFlagMar ked Then Me.Flag = "1" ElseIf oItem.FlagStatu s = Outlook.OlFlagS tatus.olFlagCom plete Then Me.Flag = "2" End If If oItem.Importanc e = Outlook.OlImpor tance.olImporta nceHigh Then Me.Flag = "1" End If Catch ex As Exception blnOk = False ErrorMessage(ex , "GetMailInfoDeb ug: " & strStatus) End Try
Return blnOk End Function
Ok, thanks a lot!
"Eric Legault [MVP - Outlook]" <el*********@RE MOVEZZZmvps.org > wrote in
message news:26******** *************** ***********@mic rosoft.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(ByV al DocList As Generic.List(Of clsDoc)) As String Dim oApp As Outlook.Applica tion Dim oExp As Outlook.Explore r Dim oSel As Outlook.Selecti on ' You need a selection object for getting the selection. Dim oFolder As Outlook.MAPIFol der Dim oItem As Outlook.MailIte m
Dim intGood As Integer = 0 Dim intTotaal As Integer = 0
Try oApp = New Outlook.Applica tion oExp = oApp.ActiveExpl orer ' Get the ActiveExplorer. oSel = oExp.Selection ' Get the selection.
Dim intX As Integer Dim clsMail As clsDocMail oFolder = oExp.CurrentFol der intTotaal = oSel.Count
For intX = 1 To (oSel.Count) Try
If oSel.Item(intX) .Class = Outlook.OlObjec tClass.olMail Then oItem = oSel.Item(intX) clsMail = New clsDocMail(oIte m, 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(Opt ional ByVal blnMove As Boolean = True) As Boolean Dim blnOk As Boolean = True
Try If blnMove Then Try If (oFolder.StoreI D <> clsDocShared.Gl obalDoc.MyOutlo okFolder.StoreI D) Or (oFolder.EntryI D <> clsDocShared.Gl obalDoc.MyOutlo okFolder.EntryI D) Then 'Move it to the right folder: StoreID oItem = oItem.Move(clsD ocShared.Global Doc.MyOutlookFo lder) End If Catch ex As Exception blnOk = False Return blnOk Exit Function End Try End If
'FolderID Me.FolderID = clsDocShared.Gl obalDoc.MyOutlo okFolderID 'FileLink = MailLink = EntryID Me.FileLink = oItem.EntryID
'From and to etc... Me.MailFrom = oItem.SenderNam e 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.Lengt h > 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.ReceivedT ime Me.AddDate = Me.MailDate
Dim intA As Integer 'premier Type identification '?oitem.Message Class = -> FAX '?oitem.Message Class = -> MAIL Dim strI As String If oItem.MessageCl ass = "IPM.FAX" Then 'received strI = "FAX" Else strI = "MAIL" End If If (strI = "MAIL") And (oItem.Recipien ts.Count > 0) Then If oItem.Recipient s.Item(1).Addre ssEntry.Type.To String = "FAX" Then 'send strI = "FAX" ElseIf oItem.SenderNam e = "FAXINSDX" Then 'een fax wordt soms doorgemaild naar iemand!!! strI = "FAX" End If End If Me.MailType = strI
If oItem.Attachmen ts.Count > 0 Then Me.MailType = Me.MailType & ".ATTACHMEN T" Me.Attachments = "" For intA = 1 To oItem.Attachmen ts.Count If intA > 1 Then Me.Attachments = Me.Attachments & ", " End If Me.Attachments = Me.Attachments & oItem.Attachmen ts.Item(intA).F ileName.ToStrin g Next End If
If oItem.FlagStatu s = Outlook.OlFlagS tatus.olFlagMar ked Then Me.Flag = "1" ElseIf oItem.FlagStatu s = Outlook.OlFlagS tatus.olFlagCom plete Then Me.Flag = "2" End If If oItem.Importanc e = Outlook.OlImpor tance.olImporta nceHigh Then Me.Flag = "1" End If Catch ex As Exception blnOk = False ErrorMessage(ex , "GetMailInfoDeb ug: " & strStatus) End Try
Return blnOk End Function This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 and installation
machine. Also the outlook version is Outlook 2002 in both development
and installation machines.
I ma using a listview to populate the mails in this form. lvwDetails
is listview. frmIn is the form's name.
|
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
Microsoft.Office.Interop.Outlook.NameSpace oNs;
oNs = Connect.oApplication.GetNamespace("MAPI");
//it shows an error here - invalid cast exception
|
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
|
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
|
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 message like '<HTML>' etc. Any idea
what I am doing wrong?
Thanks
Regards
| |
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 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
|
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 for component with CLSID {...GUID...}
failed due to the following error: 80040154."
I tried to reregister the Redemption DLL but I still get this
exception...
My OS is win server 2003 sp1 it may be the problem?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
| |
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |