| |

Suche Visual-Basic CodeRe: TIPP: Outlook - manuelle Ordnerauswahl | |  | Autor: CyberDreams | Datum: 21.04.06 10:27 |
| Anbei ein bisschen Code, der dir alle Outlook-Ordner in einem Listview darstellt. zusätzlich wird neben dem Ordnername auch die Anzahl der Elemente (eMails) in diesem Ordner angezeigt.
' (Verweis hinzufügen: Microsoft Outlook 11.0 Object Library)
' (Treeview hinzufügen: tvwOutlook)
Option Explicit
Private mbFormLoad As Boolean
Private moOutlook As Outlook.Application
Private moNameSpace As Outlook.NameSpace
Private moInbox As Outlook.MAPIFolder
'----------------------------------------------------------------------------
' Form_Activate
'----------------------------------------------------------------------------
Private Sub Form_Activate()
If mbFormLoad Then
Screen.MousePointer = vbHourglass
Call ReadOutlookFolders
mbFormLoad = False
Screen.MousePointer = vbDefault
End If
End Sub
'----------------------------------------------------------------------------
' Form_Load
'----------------------------------------------------------------------------
Private Sub Form_Load()
Screen.MousePointer = vbHourglass
mbFormLoad = True
tvwOutlook.Visible = False
' Objekte Initialisieren
Set moOutlook = New Outlook.Application
Set moNameSpace = moOutlook.GetNamespace("MAPI")
Screen.MousePointer = vbDefault
End Sub
'----------------------------------------------------------------------------
' ReadOutlookFolders
'----------------------------------------------------------------------------
Private Sub ReadOutlookFolders()
Dim i As Integer
Dim sKey As String
tvwOutlook.Visible = False
tvwOutlook.Nodes.Clear
'Reference the default Contacts folder.
Set moInbox = moNameSpace.GetDefaultFolder(olFolderInbox)
With moInbox
sKey = .Name & ";" & .Name & ";" & .EntryID & ";" & .Items.Count
Call tvwOutlook.Nodes.Add(, , sKey, .Name & " (" & .Items.Count & ")")
tvwOutlook.Nodes.Item(tvwOutlook.Nodes.Count).EnsureVisible
With .Folders
For i = 1 To .Count
Call FillTreeView(.Item(i), sKey)
DoEvents
Next i
End With
End With
tvwOutlook.Nodes.Item(1).EnsureVisible
Set moInbox = Nothing
tvwOutlook.Visible = True
End Sub
'----------------------------------------------------------------------------
' FillTreeView
'----------------------------------------------------------------------------
Private Sub FillTreeView(ByVal oFolder As Outlook.MAPIFolder, ByVal sRelative _
As String)
Dim i As Integer
Dim sKey As String
With oFolder
sKey = ExtractString(sRelative, ";", 1) & "\" & .Name & ";" & .Name & ";" & _
.EntryID & ";" & .Items.Count
Call tvwOutlook.Nodes.Add(sRelative, tvwChild, sKey, .Name & IIf( _
.Items.Count > 0, " (" & .Items.Count & ")", ""))
tvwOutlook.Nodes.Item(tvwOutlook.Nodes.Count).EnsureVisible
sRelative = sKey
For i = 1 To .Folders.Count
If .Folders.Count > 0 Then
Call FillTreeView(.Folders.Item(i), sRelative)
DoEvents
End If
Next i
End With
End Sub
'----------------------------------------------------------------------------
' ExtractString
'----------------------------------------------------------------------------
Public Function ExtractString(sString As String, sDelimiter As String, iNo As _
Integer) As String
Dim i As Integer
Dim lStart As Long
Dim lEnd As Long
On Error GoTo FAULT
lStart = 1
' Beginn des Teilstrings bestimmen
For i = 2 To iNo
lStart = InStr(lStart, sString, sDelimiter)
If lStart = 0 Then Exit For
lStart = lStart + Len(sDelimiter)
Next i
' Ende des Teilstrings bestimmen
If lStart Then
lEnd = InStr(lStart, sString, sDelimiter)
If lEnd = 0 Then lEnd = Len(sString) + 1
ExtractString = Mid(sString, lStart, lEnd - lStart)
End If
Exit Function
FAULT:
Call Err.Raise(Err.Number, , "ExtractString: " & Err.Description & "; iNo = " _
& iNo)
End Function |  |
 | Sie sind nicht angemeldet! Um auf diesen Beitrag zu antworten oder neue Beiträge schreiben zu können, müssen Sie sich zunächst anmelden.
Einloggen | Neu registrieren |
  |
|
Neu! sevEingabe 3.0 
Einfach stark!
Ein einziges Eingabe-Control für alle benötigten Eingabetypen und -formate, inkl. Kalender-, Taschenrechner und Floskelfunktion, mehrspaltige ComboBox mit DB-Anbindung, ImageComboBox u.v.m. Weitere InfosTipp des Monats Oktober 2025 Matthias KozlowskiUmlaute konvertierenErsetzt die Umlaute in einer Zeichenkette durch die entsprechenden Doppelbuchstaben (aus ä wird ae, usw.) Access-Tools Vol.1 
Über 400 MByte Inhalt
Mehr als 250 Access-Beispiele, 25 Add-Ins und ActiveX-Komponenten, 16 VB-Projekt inkl. Source, mehr als 320 Tipps & Tricks für Access und VB
Nur 24,95 EURWeitere Infos
|
|
|
Copyright ©2000-2025 vb@rchiv Dieter Otter Alle Rechte vorbehalten.
Microsoft, Windows und Visual Basic sind entweder eingetragene Marken oder Marken der Microsoft Corporation in den USA und/oder anderen Ländern. Weitere auf dieser Homepage aufgeführten Produkt- und Firmennamen können geschützte Marken ihrer jeweiligen Inhaber sein.
Diese Seiten wurden optimiert für eine Bildschirmauflösung von mind. 1280x1024 Pixel
|
|