IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

VBA Access Discussion :

Lotus 8.5 et VBA


Sujet :

VBA Access

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    470
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2009
    Messages : 470
    Par défaut Lotus 8.5 et VBA
    Bonsoir à tous.

    Me revoici avec mes Pb E N lotus et VBA.
    J'ai trouvé un code pour l'envoi d'un mail en lotus 8.5 via VBA.

    Mais le deboguage m'indique une erreur au niveau de f_intChar_Count me disant que la fonction n'était pas déclarée.

    Merci d'avance

    Habiler


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    Sub s_RecipientList(strArray() As String, strRecipientList As String)
    Dim i As Integer, j As Integer
    strRecipientList = Replace(strRecipientList, ";", ",")
    If Right(strRecipientList, 1) <> "," Then strRecipientList = strRecipientList & ","
    j = f_intChar_Count(strRecipientList, ",")
    ReDim strArray(j)
    For i = 1 To j
    strArray(i) = f_strString_Extract(strRecipientList, ",", i)
    Next i
    End Sub

  2. #2
    Membre éclairé
    Inscrit en
    Avril 2010
    Messages
    313
    Détails du profil
    Informations forums :
    Inscription : Avril 2010
    Messages : 313
    Par défaut
    Bonjour Habiler,
    As tu le code en entier?
    As tu déclaré cette fonction plus haut dans ton code?
    Fred

  3. #3
    Membre éclairé
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    470
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2009
    Messages : 470
    Par défaut
    Bonjour,

    Voici le code en entier.

    Merci d'avance

    Habiler

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    Option Compare Database
    Option Explicit
     
    Private Maildb As Object ' The Mail Database
    Private Username As String ' The current users notes name
    Private MailDbName As String ' The Current Users Notes mail database name
    Private MailDoc As Object 'the mail document itself
    Private AttachME As Object ' The attachement richtextfile object
    Private session As Object ' The Notes Seesion
    Private EmbedObj As Object ' The Embedded Object (attachment)
    Private ws As Object 'Lotus Workspace
     
    Private objProfile As Object
    Private rtiSig As Object, rtitem As Object, rtiNew As Object
    Private uiMemo As Object
    Public strToArray() As String, strCCArray() As String, strBccArray() As String
    '
    Public Function f_SendNotesEmail(strTo As String, strCC As String, strBcc As String, _
    strObject As String, strBody As String, strAttachment As String, blnSaveIt As Boolean) As Boolean
    Dim strSignText As String, strMemoUNID As String
    Dim intSignOption As Integer
     
    Set session = CreateObject("Notes.NotesSession")
    Set ws = CreateObject("Notes.NotesUIWorkspace")
     
    Username = session.Username
    MailDbName = Left$(Username, 1) & Right$(Username, (Len(Username) - InStr(1, Username, " "))) & ".nsf"
     
    On Error GoTo err_send
     
    Set Maildb = session.GETDATABASE("", MailDbName)
     
    If Maildb.IsOpen = False Then Maildb.OPENMAIL
     
    'Use Array for recipient list
    s_RecipientList strToArray(), strTo
    s_RecipientList strCCArray(), strCC
    s_RecipientList strBccArray(), strBcc
     
    Set MailDoc = Maildb.CREATEDOCUMENT
    MailDoc.Form = "Memo"
    MailDoc.SendTo = strToArray
    MailDoc.CopyTo = strCCArray
    MailDoc.BlindCopyTo = strBccArray
    MailDoc.Subject = strObject
    MailDoc.SAVEMESSAGEONSEND = blnSaveIt
     
    Set objProfile = Maildb.GetProfileDocument("CalendarProfile")
    intSignOption = objProfile.GetItemValue("SignatureOption")(0)
    strSignText = objProfile.GetItemValue("Signature")(0)
     
    If strAttachment <> "" Then
    Set AttachME = MailDoc.CreateRichTextItem("ATTACHMENT")
    Set EmbedObj = AttachME.embedobject(1454, "", strAttachment, "ATTACHMENT")
    End If
     
    'Signature or not
    If intSignOption = 0 Then
     
    MailDoc.body = strBody
     
    Else
     
    'Insert a Signature
    Select Case intSignOption
     
    Case 1: 'Plain text Signature
    Set rtitem = MailDoc.CreateRichTextItem("Body")
    Call rtitem.AppendText(strBody)
    Call rtitem.AppendText(Chr(10)): Call rtitem.AppendText(Chr(10))
    Call rtitem.AppendText(strSignText)
     
    Case 2, 3: 'Document or Rich text
     
    'Open memo in ui
    Set uiMemo = ws.EditDocument(True, MailDoc)
    Call uiMemo.GotoField("Body")
     
    'Check if the signature is automatically inserted
    If objProfile.GetItemValue("EnableSignature")(0) <> 1 Then
    If intSignOption = 2 Then
    Call uiMemo.Import(f_strSignatureType(strSignText), strSignText)
    Else
    Call uiMemo.ImportItem(objProfile, "Signature_Rich")
    End If
    End If
     
    Call uiMemo.GotoField("Body")
     
    'Save the mail doc
    strMemoUNID = uiMemo.Document.UniversalID
    uiMemo.Document.MailOptions = "0"
    Call uiMemo.Save
    uiMemo.Document.SaveOptions = "0"
    Call uiMemo.Close
    Set uiMemo = Nothing
    Set MailDoc = Nothing
     
    'Get the text and the signature
    Set MailDoc = Maildb.GetDocumentByUNID(strMemoUNID)
    Set rtiSig = MailDoc.GetFirstItem("Body")
    Set rtiNew = MailDoc.CreateRichTextItem("rtiTemp")
    Call rtiNew.AppendText(strBody)
    Call rtiNew.AppendText(Chr(10)): Call rtiNew.AppendText(Chr(10))
    Call rtiNew.AppendRTItem(rtiSig)
     
    'Remove actual body to replace it with the new one
    Call MailDoc.RemoveItem("Body")
    Set rtitem = MailDoc.CreateRichTextItem("Body")
    Call rtitem.AppendRTItem(rtiNew)
     
    End Select
     
    End If
     
    MailDoc.Save False, False
     
    Set uiMemo = ws.EditDocument(True, MailDoc)
     
    f_SendNotesEmail = True
     
    label_end:
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set AttachME = Nothing
    Set session = Nothing
    Set EmbedObj = Nothing
    Set rtitem = Nothing
    Set uiMemo = Nothing
    Set rtiSig = Nothing
    Set rtiNew = Nothing
    Set ws = Nothing
    Exit Function
     
    err_send:
    f_SendNotesEmail = False
    GoTo label_end
    End Function
     
    '---------------------------------------------------------------------------------------
    ' Procedure : f_strSignatureType
    ' Author : c159
    ' Date : 30/10/2012
    ' Purpose : Returns the Type of Import to do in Lotus
    '---------------------------------------------------------------------------------------
    '
    Function f_strSignatureType(strFile As String) As String
    Dim strExt As String
    Dim i As Integer
    strExt = ""
    For i = Len(strFile) To 1 Step -1
    If Mid(strFile, i, 1) = "." Then
    strExt = UCase(Mid(strFile, i + 1))
    Exit For
    End If
    Next i
     
    Select Case strExt
    Case "": f_strSignatureType = ""
    Case "JPG": f_strSignatureType = "JPEG Image"
    Case "JPEG": f_strSignatureType = "JPEG Image"
    Case "BMP": f_strSignatureType = "BMP Image"
    Case "GIF": f_strSignatureType = "GIF Image"
    Case "HTM": f_strSignatureType = "HTM"
    Case "HTML": f_strSignatureType = "HTM"
    Case "TXT": f_strSignatureType = "ASCII"
    End Select
    End Function
     
    '---------------------------------------------------------------------------------------
    ' Procedure : s_RecipientList
    ' Author : c159
    ' Date : 2014-03-20
    ' Purpose : Create the recipient list in an array
    '---------------------------------------------------------------------------------------
    '
    Sub s_RecipientList(strArray() As String, strRecipientList As String)
    Dim i As Integer, j As Integer
    strRecipientList = Replace(strRecipientList, ";", ",")
    If Right(strRecipientList, 1) <> "," Then strRecipientList = strRecipientList & ","
    j = f_intChar_Count(strRecipientList, ",")
    ReDim strArray(j)
    For i = 1 To j
    strArray(i) = f_strString_Extract(strRecipientList, ",", i)
    Next i
    End Sub

  4. #4
    Membre éclairé
    Inscrit en
    Avril 2010
    Messages
    313
    Détails du profil
    Informations forums :
    Inscription : Avril 2010
    Messages : 313
    Par défaut
    Bonjour Habiler
    Ce code semble très complet et assez compliqué (en tout cas pour moi). Visiblement la focntion n'est pas déclarée et c'est pour cela que ca bugg.
    Je n'ai pas trop eu le temps d'approfondir le sujet.
    Par contre, j'utilise le bout de code suivant pour envoyer des mails via excel en VBA avec lotus notes 8.5 et ca marche très bien

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    Sub Envoi_Mail()
    Dim oSess As Object, oDB As Object, oDoc As Object, oItem As Object
    Dim FileSaveName As String
    Dim flag As Boolean
    Dim i As Integer
     
    '
    'Ouverture de la session lotus notes
    Set oSess = CreateObject("Notes.NotesSession")
    Set oDB = oSess.GETDATABASE("", "")
    Call oDB.OPENMAIL
    flag = True
    If Not (oDB.IsOpen) Then flag = oDB.Open("", "")
     
    If Not flag Then
    MsgBox "Can't open mail file: " & oDB.SERVER & " " & oDB.FILEPATH
    GoTo exit_SendAttachment
    End If
    On Error GoTo err_handler
     
     
    'Conctruction du message
    Set oDoc = oDB.CREATEDOCUMENT
    Set oItem = oDoc.CREATERICHTEXTITEM("BODY")
    oDoc.Form = "Memo"
    oDoc.Subject = "Entrer le sujet du mail"
    oDoc.sendto = "adresse mail du destinataire"
    oDoc.body = "Mettre le texte contenu dans le mail"
    oDoc.postdate = Date
    oDoc.SAVEMESSAGEONSEND = True
     
    'Attache piece jointe
    FileSaveName = "chemin vers une pièce jointe si envoi de pièce jointe"
    Call oItem.EmbedObject(1454, "", FileSaveName)
    oDoc.visable = True
     
     
    'Sending Message
    oDoc.SEND False
    exit_SendAttachment:
    On Error Resume Next
    Set oSess = Nothing
    Set oDB = Nothing
    Set oDoc = Nothing
    Set oItem = Nothing
    'Done
    Exit Sub
    err_handler:
    If Err.Number = 7225 Then
    MsgBox "File doesn't exist"
    Else
    MsgBox Err.Number & " " & Err.Description
    End If
    On Error GoTo exit_SendAttachment
    End Sub
    A toi de l'adapter à ton application.

    Fred

  5. #5
    Membre éclairé
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    470
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2009
    Messages : 470
    Par défaut
    Bonsoir,

    Merci pour ton aide.

    Lors de l'exécution il me met une erreur d'exécution 91.

    Quelqu'un pourrait m'aider.

    l'erreur se situe semble-t-il au niveau de oDoc, mais sans certitude

    Merci encore

    Habiler

  6. #6
    Membre éclairé
    Inscrit en
    Avril 2010
    Messages
    313
    Détails du profil
    Informations forums :
    Inscription : Avril 2010
    Messages : 313
    Par défaut
    Bonjour Habiler,
    Je viens de le tester et ca marche chez moi.
    Tu mets une pièce jointe ou pas?
    Tu as bien mis l'email entre le ""?
    Quand tu executes ton code pas à pas, sur quelle ligne ca bloque?
    Fred

  7. #7
    Membre éclairé
    Profil pro
    Inscrit en
    Janvier 2009
    Messages
    470
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Janvier 2009
    Messages : 470
    Par défaut
    Bonsoir à tous.

    Vraiment personne pour m'aider ..

    Le déboguage m'indique une erreur au niveau de f_intChar_Count me disant que la fonction n'était pas déclarée.

    Merci d'avance

    Habiler

Discussions similaires

  1. [AC-2007] Envoi mail via lotus 8.5 par VBA
    Par HABILER dans le forum VBA Access
    Réponses: 8
    Dernier message: 07/04/2015, 14h21
  2. Réponses: 3
    Dernier message: 02/05/2014, 23h15
  3. Lien base Lotus Notes avec VBA Word 2003
    Par ISA53 dans le forum VBA Word
    Réponses: 3
    Dernier message: 17/11/2006, 12h07
  4. Lotus Notes - Enregistrer Pièce Jointe par VBA
    Par Peterson82 dans le forum Général VBA
    Réponses: 1
    Dernier message: 17/10/2006, 06h54
  5. [VBA-E]Envoyer un "tableau" avec Lotus
    Par illight dans le forum Macros et VBA Excel
    Réponses: 3
    Dernier message: 25/05/2006, 14h56

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo