Accueil > > > MINI CLIENT NOTES ECRIT EN VB5 !
MINI CLIENT NOTES ECRIT EN VB5 !
Information sur la source
Description
Démonstration de l'utilisation des object COM de Lotus Notes. (Version 5 minimum) pour faire un petit "client" Notes en VB5 (lecture et affichage des message reçu) Merci à Oguruma, modérateur de www.dominoarea.org (Forum Lotus Notes en Français)
Source
- VERSION 5.00
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 5580
- ClientLeft = 60
- ClientTop = 450
- ClientWidth = 6885
- LinkTopic = "Form1"
- ScaleHeight = 5580
- ScaleWidth = 6885
- StartUpPosition = 3 'Windows Default
- Begin VB.CommandButton CmdMove
- Caption = "Move To"
- Enabled = 0 'False
- Height = 375
- Left = 5880
- TabIndex = 10
- Top = 120
- Width = 855
- End
- Begin VB.TextBox Folder
- Height = 375
- Left = 3240
- TabIndex = 9
- Top = 120
- Width = 2655
- End
- Begin VB.CommandButton CmdLast
- Caption = ">> |"
- Enabled = 0 'False
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 2280
- TabIndex = 8
- Top = 120
- Width = 615
- End
- Begin VB.CommandButton CmdNext
- Caption = ">"
- Enabled = 0 'False
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 1560
- TabIndex = 7
- Top = 120
- Width = 615
- End
- Begin VB.CommandButton CmdPrevious
- Caption = "<"
- Enabled = 0 'False
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 840
- TabIndex = 6
- Top = 120
- Width = 615
- End
- Begin VB.TextBox From
- Height = 375
- Left = 1200
- Locked = -1 'True
- TabIndex = 3
- Top = 1080
- Width = 5535
- End
- Begin VB.CommandButton cmdFirst
- Caption = "| <<"
- Enabled = 0 'False
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 8.25
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 375
- Left = 120
- TabIndex = 2
- Top = 120
- Width = 615
- End
- Begin VB.TextBox Body
- Height = 3855
- Left = 120
- Locked = -1 'True
- MultiLine = -1 'True
- ScrollBars = 3 'Both
- TabIndex = 1
- Top = 1560
- Width = 6615
- End
- Begin VB.TextBox subject
- Height = 375
- Left = 1200
- Locked = -1 'True
- TabIndex = 0
- Top = 720
- Width = 5535
- End
- Begin VB.Label Label
- Alignment = 1 'Right Justify
- BackStyle = 0 'Transparent
- Caption = "De :"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 12
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 1
- Left = 240
- TabIndex = 5
- Top = 1080
- Width = 855
- End
- Begin VB.Label Label
- Alignment = 1 'Right Justify
- BackStyle = 0 'Transparent
- Caption = "Sujet :"
- BeginProperty Font
- Name = "MS Sans Serif"
- Size = 12
- Charset = 0
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 0
- Left = 240
- TabIndex = 4
- Top = 720
- Width = 855
- End
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Option Explicit
-
- '-----------------------------------------------------------------------------
- ' (C)2005 by Patrick MOIRE
- '------------------------------------------------------------------------------
- ' DEMO UTILISATION DES OBJETS COM de Lotus Notes
- '
- ' Merci à Oguruma, modérateur de www.dominoarea.org (Forum Lotus Notes en Français)
-
-
- Private session As New NotesSession
- Private dir As NotesDbDirectory
- Private db As NotesDatabase
- Private View As NotesView
- Private doc As NotesDocument
-
-
- '------------------------------------------------------------------------------------
- ' Connection a Lotus Notes
- '------------------------------------------------------------------------------------
-
- Private Sub Form_Paint()
-
- Me.AutoRedraw = True
- DoEvents
-
- Me.Caption = "Connexion en cours..."
-
- session.Initialize
- ' PS : en cas de problème, remplacer par :
- '
- ' session.Initialize "password"
- '
- ' voir :
- '
- ' session.InitializeUsingNotesUserName "User", "password"
- '
-
- Set dir = session.GetDbDirectory("")
- Set db = dir.OpenMailDatabase
-
- Me.Caption = db.filename
-
- Set View = db.GetView("($inbox)")
- Me.Caption = db.filename & " : " & View.Name
-
- Call cmdFirst_Click
-
- End Sub
-
-
- '------------------------------------------------------------------------------------
- ' Déplacement dans la liste des couriers
- '------------------------------------------------------------------------------------
-
- Private Sub cmdFirst_Click()
- Set doc = View.GetFirstDocument
- Me.CmdNext.Enabled = (Not doc Is Nothing)
- Me.CmdPrevious.Enabled = False
- Call Affiche
- End Sub
-
- Private Sub CmdPrevious_Click()
- If Not doc Is Nothing Then
- Set doc = View.GetPrevDocument(doc)
- Me.CmdNext.Enabled = True
- Me.CmdPrevious.Enabled = Not (View.GetPrevDocument(doc) Is Nothing)
- End If
- Call Affiche
- End Sub
-
- Private Sub CmdNext_Click()
- If Not doc Is Nothing Then
- Set doc = View.GetNextDocument(doc)
- Me.CmdPrevious.Enabled = True
- Me.CmdNext.Enabled = Not (View.GetNextDocument(doc) Is Nothing)
- End If
- Call Affiche
- End Sub
-
- Private Sub CmdLast_Click()
- Set doc = View.GetLastDocument
- Me.CmdNext.Enabled = False
- Call Affiche
- End Sub
-
-
- '------------------------------------------------------------------------------------
- ' Affichage d'un courier
- '------------------------------------------------------------------------------------
-
- Private Sub Affiche()
-
- Me.CmdMove.Enabled = (Not doc Is Nothing)
- Me.cmdFirst.Enabled = Me.CmdPrevious.Enabled
- Me.CmdLast.Enabled = Me.CmdNext.Enabled
-
- Me.subject.Text = ""
- Me.From.Text = ""
- Me.Body.Text = ""
-
- If Not doc Is Nothing Then
- If doc.HasItem("subject") Then Me.subject.Text = doc.GetItemValue("subject")(0)
- If doc.HasItem("from") Then Me.From.Text = doc.GetItemValue("from")(0)
- If doc.HasItem("body") Then Me.Body.Text = doc.GetItemValue("body")(0)
- End If
-
- End Sub
-
-
- '------------------------------------------------------------------------------------
- ' Deplacement d'un document dans un "folder"
- '------------------------------------------------------------------------------------
-
- Private Sub CmdMove_Click()
- moveToFolder db, doc, Me.Folder.Text
- End Sub
-
- Function moveToFolder(dbMailbox As NotesDatabase, docMailbox As NotesDocument, folderName As String) As Boolean
- Dim docMailBoxCopy As NotesDocument
- On Error GoTo handleError
- Set docMailBoxCopy = docMailbox.CopyToDatabase(dbMailbox)
- docMailBoxCopy.PutInFolder folderName, True
- docMailbox.Remove True
- On Error GoTo 0
- moveToFolder = True
- Exit Function
- handleError:
- MsgBox "Error # " & Err & " : " & Error$ & " - line " & Erl, 16, "DEMOA Notes Error - moveToFolder"
- End Function
-
-
- '------------------------------------------------------------------------------------
- ' Déconnection de Lotus Notes
- '------------------------------------------------------------------------------------
-
- Private Sub Form_Unload(Cancel As Integer)
- Set doc = Nothing
- Set View = Nothing
- Set db = Nothing
- Set dir = Nothing
- Set session = Nothing
- End Sub
VERSION 5.00
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 5580
ClientLeft = 60
ClientTop = 450
ClientWidth = 6885
LinkTopic = "Form1"
ScaleHeight = 5580
ScaleWidth = 6885
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton CmdMove
Caption = "Move To"
Enabled = 0 'False
Height = 375
Left = 5880
TabIndex = 10
Top = 120
Width = 855
End
Begin VB.TextBox Folder
Height = 375
Left = 3240
TabIndex = 9
Top = 120
Width = 2655
End
Begin VB.CommandButton CmdLast
Caption = ">> |"
Enabled = 0 'False
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 2280
TabIndex = 8
Top = 120
Width = 615
End
Begin VB.CommandButton CmdNext
Caption = ">"
Enabled = 0 'False
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 1560
TabIndex = 7
Top = 120
Width = 615
End
Begin VB.CommandButton CmdPrevious
Caption = "<"
Enabled = 0 'False
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 840
TabIndex = 6
Top = 120
Width = 615
End
Begin VB.TextBox From
Height = 375
Left = 1200
Locked = -1 'True
TabIndex = 3
Top = 1080
Width = 5535
End
Begin VB.CommandButton cmdFirst
Caption = "| <<"
Enabled = 0 'False
BeginProperty Font
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 120
TabIndex = 2
Top = 120
Width = 615
End
Begin VB.TextBox Body
Height = 3855
Left = 120
Locked = -1 'True
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 1
Top = 1560
Width = 6615
End
Begin VB.TextBox subject
Height = 375
Left = 1200
Locked = -1 'True
TabIndex = 0
Top = 720
Width = 5535
End
Begin VB.Label Label
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "De :"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 1
Left = 240
TabIndex = 5
Top = 1080
Width = 855
End
Begin VB.Label Label
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
Caption = "Sujet :"
BeginProperty Font
Name = "MS Sans Serif"
Size = 12
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Index = 0
Left = 240
TabIndex = 4
Top = 720
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'-----------------------------------------------------------------------------
' (C)2005 by Patrick MOIRE
'------------------------------------------------------------------------------
' DEMO UTILISATION DES OBJETS COM de Lotus Notes
'
' Merci à Oguruma, modérateur de www.dominoarea.org (Forum Lotus Notes en Français)
Private session As New NotesSession
Private dir As NotesDbDirectory
Private db As NotesDatabase
Private View As NotesView
Private doc As NotesDocument
'------------------------------------------------------------------------------------
' Connection a Lotus Notes
'------------------------------------------------------------------------------------
Private Sub Form_Paint()
Me.AutoRedraw = True
DoEvents
Me.Caption = "Connexion en cours..."
session.Initialize
' PS : en cas de problème, remplacer par :
'
' session.Initialize "password"
'
' voir :
'
' session.InitializeUsingNotesUserName "User", "password"
'
Set dir = session.GetDbDirectory("")
Set db = dir.OpenMailDatabase
Me.Caption = db.filename
Set View = db.GetView("($inbox)")
Me.Caption = db.filename & " : " & View.Name
Call cmdFirst_Click
End Sub
'------------------------------------------------------------------------------------
' Déplacement dans la liste des couriers
'------------------------------------------------------------------------------------
Private Sub cmdFirst_Click()
Set doc = View.GetFirstDocument
Me.CmdNext.Enabled = (Not doc Is Nothing)
Me.CmdPrevious.Enabled = False
Call Affiche
End Sub
Private Sub CmdPrevious_Click()
If Not doc Is Nothing Then
Set doc = View.GetPrevDocument(doc)
Me.CmdNext.Enabled = True
Me.CmdPrevious.Enabled = Not (View.GetPrevDocument(doc) Is Nothing)
End If
Call Affiche
End Sub
Private Sub CmdNext_Click()
If Not doc Is Nothing Then
Set doc = View.GetNextDocument(doc)
Me.CmdPrevious.Enabled = True
Me.CmdNext.Enabled = Not (View.GetNextDocument(doc) Is Nothing)
End If
Call Affiche
End Sub
Private Sub CmdLast_Click()
Set doc = View.GetLastDocument
Me.CmdNext.Enabled = False
Call Affiche
End Sub
'------------------------------------------------------------------------------------
' Affichage d'un courier
'------------------------------------------------------------------------------------
Private Sub Affiche()
Me.CmdMove.Enabled = (Not doc Is Nothing)
Me.cmdFirst.Enabled = Me.CmdPrevious.Enabled
Me.CmdLast.Enabled = Me.CmdNext.Enabled
Me.subject.Text = ""
Me.From.Text = ""
Me.Body.Text = ""
If Not doc Is Nothing Then
If doc.HasItem("subject") Then Me.subject.Text = doc.GetItemValue("subject")(0)
If doc.HasItem("from") Then Me.From.Text = doc.GetItemValue("from")(0)
If doc.HasItem("body") Then Me.Body.Text = doc.GetItemValue("body")(0)
End If
End Sub
'------------------------------------------------------------------------------------
' Deplacement d'un document dans un "folder"
'------------------------------------------------------------------------------------
Private Sub CmdMove_Click()
moveToFolder db, doc, Me.Folder.Text
End Sub
Function moveToFolder(dbMailbox As NotesDatabase, docMailbox As NotesDocument, folderName As String) As Boolean
Dim docMailBoxCopy As NotesDocument
On Error GoTo handleError
Set docMailBoxCopy = docMailbox.CopyToDatabase(dbMailbox)
docMailBoxCopy.PutInFolder folderName, True
docMailbox.Remove True
On Error GoTo 0
moveToFolder = True
Exit Function
handleError:
MsgBox "Error # " & Err & " : " & Error$ & " - line " & Erl, 16, "DEMOA Notes Error - moveToFolder"
End Function
'------------------------------------------------------------------------------------
' Déconnection de Lotus Notes
'------------------------------------------------------------------------------------
Private Sub Form_Unload(Cancel As Integer)
Set doc = Nothing
Set View = Nothing
Set db = Nothing
Set dir = Nothing
Set session = Nothing
End Sub
Conclusion
Allez... j'en profite pour mettre un code pour envoyer un email via Notes. Pas de moi, mais fait un bon complément à mon code !
Private Sub Send()
Dim session As Object Dim db As Object Dim doc As Object
Set session = CreateObject("Notes.NotesSession") Set db = session.GetDatabase("", "") Call db.OPENMAIL
Set doc = db.CreateDocument() With doc .Form = "Memo" .SendTo = "adresse@serveur.com" .CopyTo = "adresse@serveur.com" .subject = "Petit test" .Body = "Ceci est un petit test d'envoie de message" .From = session.CommonUserName .PostedDate = Now .SaveMessageOnSend = True End With Call doc.Send(True)
Set session = Nothing Set db = Nothing Set doc = Nothing
End Sub
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
SESSION SILVERLIGHT 5 3D : SLIDES ET DEMOSSESSION SILVERLIGHT 5 3D : SLIDES ET DEMOS par Groc
Durant les techdays, j'ai eu le plaisir d'animer une session sur Silverlight 5 et la 3D avec Simon Ferquel. Comme promis, voici nos slides et mes démos (celles avec le viper BSG) ici et là. Pour mémoire, les démos utilisent toutes le viper BSG...
Cliquez pour lire la suite de l'article par Groc [TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES[TECHDAYS 2012] SESSION WEBMATRIX 2 : LE COUTEAU SUISSE GRATUIT POUR VOS DéVELOPPEMENTS WEB - SLIDES par gpommier
Suite à la session que j'ai présenté sur WebMatrix 2, vous pouvez trouver les slides ici, ainsi que les démos en packages nuget : démos1 et démos2 J'en profite pour remercier chaleureusement tous ceux qui sont venus très nombreux à cette sess...
Cliquez pour lire la suite de l'article par gpommier [SHAREPOINT] LES SESSIONS TECHDAYS 2012.[SHAREPOINT] LES SESSIONS TECHDAYS 2012. par Patrick Guimonet
Voici donc pour ceux qui n'ont pas pu venir, ou ceux qui n'ont pas pu toutes les suivre la liste des sessions SharePoint aux TechDays 2012, que je mettrais à jour dès que les liens des vidéo seront disponibles. Ou ici : http...
Cliquez pour lire la suite de l'article par Patrick Guimonet TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3TECHDAYS PARIS 2012 : SESSION PLEINIèRE JOUR 3 par ROMELARD Fabrice
Speaker: Bernard Ourghanlian Cette session est comme chaque jour transmise en live par BrainSonic, et j'ai donc suivi cette troisième pleinière par ce moyen sur mon iPad . Elle est dédiée comme chaque année à la mise en perspective de l'é...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE !MISHRA READER : UN LECTEUR RSS TRèS ZUNE STYLE EN OPEN SOURCE ! par Vko
Hier durant une session dédiée aux Techdays 2012, j'ai eu le plaisir d'annoncer la sortie de la Béta 2 de Mishra Reader. C'est quoi ? Pour les utilisateurs, c'est une vraie expérience de lecture de flux RSS sur Windows. Rien à voir avec les produit...
Cliquez pour lire la suite de l'article par Vko
Logiciels
PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System Easy-Planning (1.0.0.1)EASY-PLANNING (1.0.0.1)Basé sur les mêmes principes que MyPlanning, Easy-Planning permet de créer des plannings sous la ... Cliquez pour télécharger Easy-Planning COLLECTOR PLUS (3.00B)COLLECTOR PLUS (3.00B)COLLECTOR PLUS version 3.00B est un logiciel utilisant une base de données alimentée par :
- L... Cliquez pour télécharger COLLECTOR PLUS LettresFaciles 2011 (8.0.0.1)LETTRESFACILES 2011 (8.0.0.1)LettresFaciles est un logiciel facilitant la création et la rédaction de lettres types.
Son inte... Cliquez pour télécharger LettresFaciles 2011
|