Précédent   Forum des professionnels en informatique > Logiciels > Microsoft Office > Access > VBA Access
VBA Access Le forum pour les questions relatives au code VBA sous Access, et à son environnement de développement VBE.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 06/08/2011, 17h50   #1
Futur Membre du Club
 
Inscription : janvier 2008
Messages : 304
Détails du profil
Informations forums :
Inscription : janvier 2008
Messages : 304
Points : 18
Points : 18
Par défaut Envoyer par mail 2 pièces jointes via access et lotus notes

Bonjour,
Je tourne en rond car j’essaye d’adapter mon code pour envoyer par mail lotus notes via access deux états :
Soit deux pièces jointes.

1-/ Comment faire pour envoyer le mail et attacher les pièces jointes en même tps?Les états dans access sont : projet 1 et projet 2

2-/Quels sont les modif à faire dans mon script ?


3-/ Comment puis-je tester le fonctionnement sur un autre pc qui ne possède pas lotus notes, une sorte de test de fonctionnement ?

Merci pour votre aide

Code :
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
Public Sub SendNotesMail(ByVal Subject As String, ByVal projet 1 and projet 2 As String, _
                         ByVal Recipient As String, ByVal ccRecipient As String, _
                         ByVal bccRecipient As String, ByVal BodyText As String, _
                         ByVal SaveIt As Boolean, ByVal Password As String)
 
    Dim Maildb As Object      'La base des mails
    Dim UserName As String    'Le nom d'utilisateur
    Dim MailDbName As String  'Le nom de la base des mails
    Dim MailDoc As Object     'Le mail
    Dim AttachME As Object    'L'objet pièce jointe en RTF
    Dim Session As Object     'La session Notes
    Dim EmbedObj As Object    'L'objet incorporé
 
    'Crée une session notes
    Set Session = CreateObject("Notes.NotesSession")
 
    '*** Cette ligne est réservée aux versions 5.x et supérieur : ***
    Session.Initialize (Password)
 
    'Récupère le nom d'utilisateur et crée le nom de la base des mails
    UserName = Session.UserName
    MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
 
    'Ouvre la base des mails
    Set Maildb = Session.GETDATABASE("", MailDbName)
    If Not Maildb.ISOPEN Then Maildb.OPENMAIL
 
    'Paramètre le mail à envoyer
    Set MailDoc = Maildb.CREATEDOCUMENT
    MailDoc.Form = "Memo"
    MailDoc.sendto = Recipient
    MailDoc.CopyTo = ccRecipient
    MailDoc.BlindCopyTo = bccRecipient
    MailDoc.Subject = Subject
    MailDoc.Body = BodyText
    MailDoc.SAVEMESSAGEONSEND = SaveIt
 
    'Prend en compte les pièces jointes
    If projet 1 and projet 2 <> "" Then
        Set AttachME = MailDoc.CREATERICHTEXTITEM("projet 1 and projet 2")
        Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", projet 1 and projet 2, "projet 1 and projet 2")
        MailDoc.CREATERICHTEXTITEM ("projet 1 and projet 2")
    End If
 
    'Envoie le mail
    MailDoc.PostedDate = Now()
    MailDoc.SEND 0, Recipient
 
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set AttachME = Nothing
    Set Session = Nothing
    Set EmbedObj = Nothing
End Sub
Debutant10 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/08/2011, 13h31   #2
Responsable Visual Basic
 
Avatar de bbil
 
Inscription : juin 2003
Messages : 11 773
Détails du profil
Informations personnelles :
Âge : 45
Localisation : France, Ariège (Midi Pyrénées)

Informations forums :
Inscription : juin 2003
Messages : 11 773
Points : 16 847
Points : 16 847
Envoyer un message via Skype™ à bbil
Comme il y as plusieurs demande ... je commence par la 3) qui vas peu-être rendre caduque toutes les autres...

Citation:
3-/ Comment puis-je tester le fonctionnement sur un autre pc qui ne possède pas lotus notes, une sorte de test de fonctionnement ?
Comme cela est précisé dans ton titre,ton code utilise Lotus Notes pour envoyer des mails et donc si tu n'as pas lotus notes sur ton PC tu ne peu-aps envoyer des mails avec (lotus notes..)
bbil est déconnecté   Envoyer un message privé Réponse avec citation 20
Vieux 07/08/2011, 15h20   #3
Rédacteur/Modérateur
 
Avatar de Philippe JOCHMANS
 
Homme Philippe JOCHMANS
Développeur informatique
Inscription : mai 2005
Messages : 17 619
Détails du profil
Informations personnelles :
Nom : Homme Philippe JOCHMANS
Âge : 44
Localisation : France, Loir et Cher (Centre)

Informations professionnelles :
Activité : Développeur informatique
Secteur : Communication - Médias

Informations forums :
Inscription : mai 2005
Messages : 17 619
Points : 30 956
Points : 30 956
Envoyer un message via MSN à Philippe JOCHMANS Envoyer un message via Skype™ à Philippe JOCHMANS
Bonjour

En plus, il faut rajouter que tu ne pourras joindre un état tel quel, le mieux est de le transformer en PDF avant l'envoi.

Le mieux, quel que soit le logiciel de messagerie est d'utiliser la méthode CDO (il y a tout dans la FAQ et les sources Access du forum).

Philippe
__________________
Détaillez vos questions, sinon vous aurez des réponses erronées et vous irez tout droit dans le et lisez les règles sinon
Si vous pensez commencer sans un livre, oublier : livres pour débuter
Vous pouvez consulter mes articles sur Access et PowerPoint
Le blog Office.

Inutile de m'envoyer un MP pour des questions techniques ou de me relancer , je n'y répondrais pas.
Philippe JOCHMANS est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/08/2011, 17h31   #4
Futur Membre du Club
 
Inscription : janvier 2008
Messages : 304
Détails du profil
Informations forums :
Inscription : janvier 2008
Messages : 304
Points : 18
Points : 18
Par défaut Envoyer 2 états par mail via access / lotus notes

Bonjour,

Merci Philippe pour l'indication, voici les étapes que je pense utiliser

1-/ Utiliser une procédure VBA qui transforme en PDF des états avant l'envoi dans mon script. 2-/ Utiliser la méthode CDO

Voici ce que j'ai trouvé d'intéressant sur le FAQ :
Exporter un etat en PDF

Création du PDF :

Code :
1
2
3
4
5
6
7
8
9
10
11
Private Sub subCreatePDFFromReport(ByVal ReportName As String, _
  ByVal PDFFileName As String) 
  originalPrinter = fnctGetDefaultPrinter() 
  SetDefaultPrinter "Acrobat PDFWriter" 
  subRegistrySetKeyValue rootHKeyCurrentUser, _
   "Software\Adobe\Acrobat PDFWriter\", "PDFFileName", _
     PDFFileName, RRKREGSZ 
 
  DoCmd.OpenReport ReportName, 0 
  SetDefaultPrinter originalPrinter 
End Sub
Code :
1
2
3
Private Sub ImprimerPDF() 
  subCreatePDFFromReport "Projet 1", "C:\Poubelle\PDF\FactureClient.pdf" 
End Sub
'ici j'ai renseigné mon état



Comment envoyer un mail avec une pièce attachée mais cette solution marche avec outlook, comment l'adapter avec lotus ?

Code :
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
Option Compare Database
Option Explicit
 
Private Sub cmdEnvoyer_Click()
'txtForm
    CDOSendMail txtFrom, txtTo, txtSubject, txtBody, txtAttach
    'txtForm : Mail de l'envoyeur
    'txtTo : Mail de destination
    'txtSubject = Objet
    'txtBody = contenu
    'txtAttach = chemin complet du fichier
End Sub
 
Public Sub CDOSendMail(SendFrom As String, _
                       SendTo As String, _
                       Subject As String, _
                       PlainTextBody As String, _
                       FullPathFileName As String)
Dim cdoMail As CDO.Message
Dim iBp As CDO.IBodyPart ' for IBodyPart on message
Dim iBp1 As CDO.IBodyPart
Dim Flds As ADODB.Fields
Dim Stm  As ADODB.Stream
 
    Set cdoMail = New CDO.Message
    With cdoMail
        .From = SendFrom
        .To = SendTo
        .Subject = Subject
        ''Set iBp = .BodyPart
        Set iBp = cdoMail   '??
 
        ' TEXT BODYPART
        ' Add the body part for the text/plain part of message
        Set iBp1 = iBp.AddBodyPart
 
        ' set the fields here
        Set Flds = iBp1.Fields
        Flds("urn:schemas:mailheader:content-type") = "text/plain; charset=""iso-8859-1"""
        Flds.Update
 
        ' get the stream and add the message
        Set Stm = iBp1.GetDecodedContentStream
        Stm.WriteText PlainTextBody
        Stm.Flush
 
        ' HTML BODYPART
        ' Do the HTML part here
        Set iBp1 = iBp.AddBodyPart
        ' set the content-type field here
        Set Flds = iBp1.Fields
        Flds("urn:schemas:mailheader:content-type") = "text/html"
        Flds.Update
        ' get the stream and add message HTML text to it
        Set Stm = iBp1.GetDecodedContentStream
        Stm.WriteText "<HTML><H1>this is some content for the body part object</H1></HTML>"
        Stm.Flush
 
        ' Now set the Message object's Content-Type header
        ' to multipart/alternative
        Set Flds = iBp.Fields
        Flds("urn:schemas:mailheader:content-type") = "multipart/alternative"
        Flds.Update
        .AddAttachment FullPathFileName
        .Send
    End With
End Sub
Est-ce la bonne méthode ? ou on peut on faire plus simple pour envoyer 2 états par mail via access ?
Debutant10 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 07/08/2011, 19h44   #5
Responsable Visual Basic
 
Avatar de bbil
 
Inscription : juin 2003
Messages : 11 773
Détails du profil
Informations personnelles :
Âge : 45
Localisation : France, Ariège (Midi Pyrénées)

Informations forums :
Inscription : juin 2003
Messages : 11 773
Points : 16 847
Points : 16 847
Envoyer un message via Skype™ à bbil
Vu la réponse à ma précédente question je suppose que le client lotus notes est installé sur tes pc pour l'envoi de mail via lotus : tu as la fonction
SendNotesMail ici :
Lotus - Préparer/Envoyer un message via Lotus Notes avec option de sauvegarde.
bbil est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 09/08/2011, 20h18   #6
Futur Membre du Club
 
Inscription : janvier 2008
Messages : 304
Détails du profil
Informations forums :
Inscription : janvier 2008
Messages : 304
Points : 18
Points : 18
Par défaut Comment faire simple ? Y-a-t-il une base exemple ?

Merci pour l'information, comment puis-je l'adpater cela à mon cas ? (car code très long et un peu perdu...

Y-a-t-il une base exemple ?

J'ai deux états : projet 1 et projet 2 je voudrais faire vraiement simple, envoyer via base access par notes.
Merci pour votre aide, si une base exemple en pièce jointe





Procédure globale:

Code :
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
Public Sub SendNotesMail(ByVal Subject As String, _
ByVal Attachment As String, ByVal RECIPIENT As String, _
ByVal CC As String, ByVal BCC As String, _
ByVal BodyText As String, ByVal SaveIt As Boolean) 
 
Dim oMaildb As Object 
Dim oMailDoc As Object 
Dim oAttachME As Object 
Dim oSession As Object 
Dim oEmbedObj As Object 
 
Dim sUserName As String 
Dim sMailDbName As String 
 
Const STR_ATTACHMENT As String = "Attachment" 
 
On Error GoTo L_ErrCannotCreateNotesSession 
    Set oSession = CreateObject("Notes.NotesSession") 
    sUserName = oSession.sUserName 
    sMailDbName = Left$(sUserName, 1) & Right$(sUserName, _
         (Len(sUserName) - InStr(1, sUserName, " "))) & ".nsf" 
    DoEvents 
    lblStatus.Caption = "Information about sender..." 
    Call Sleep(1000) 
    Set oMaildb = oSession.GETDATABASE(vbNullString, _
             sMailDbName) 
     If oMaildb.IsOpen = True Then 
     Else 
         oMaildb.OPENMAIL 
     End If 
    Set oMailDoc = oMaildb.CREATEDOCUMENT 
    oMailDoc.Form = "Memo" 
    oMailDoc.SENDTO = RECIPIENT 
    If Len(CC) = 0 Then 
    Else 
        oMailDoc.CopyTo = BC 
    End If 
    If Len(BCC) = 0 Then 
    Else 
        oMailDoc.blindCopyTo = BCC 
    End If 
    oMailDoc.Subject = Subject 
    oMailDoc.Body = BodyText 
    oMailDoc.SAVEMESSAGEONSEND = SaveIt 
    DoEvents 
    lblStatus.Caption = "Looking for attached files..." 
    Call Sleep(1000) 
 
    If Attachment <> vbNullString Then 
        Set oAttachME = oMailDoc.CREATERICHTEXTITEM_
           (STR_ATTACHMENT) 
        Set oEmbedObj = oAttachME.EMBEDOBJECT(1454, _
                vbNullString, Attachment, STR_ATTACHMENT) 
        oMailDoc.CREATERICHTEXTITEM _
                (STR_ATTACHMENT) 
    End If 
    DoEvents 
    oMailDoc.PostedDate = Now() 
 
 
 'To send the message, remove the quotes characters (') near each line 
  ' lblStatus.Caption = "Sending message..." 
  ' Call Sleep(1000) 
  '
  ' oMailDoc.SEND 0, RECIPIENT 
  ' lblStatus.Caption = "Message sent" 
 
  ' MsgBox "Your message has been sent successfully...", 64, "End" 
 
 
L_ExCannotCreateNotesSession: 
    Set oMaildb = Nothing 
    Set oMailDoc = Nothing 
    Set oAttachME = Nothing 
    Set oSession = Nothing 
    Set oEmbedObj = Nothing 
    Exit Sub 
L_ErrCannotCreateNotesSession: 
  Select Case Err 
      Case 429 
          MsgBox "Impossible de localiser un Client Notes; " & _
                     "Votre message n'a pas été envoyé !", 16, _
                          "Lotus Notes requis" 
      Case Else 
          MsgBox "Un erreur a empêché l'envoi du message." & _
                  vbCrlf & "Veuillez en référer à votre administrateur " & _
                      "pour lui soumettre cette erreur..." & vbCrlf & Error ,_
                             16, "Error #" & Str(Err) 
  End Select 
  Resume L_ExCannotCreateNotesSession 
End Sub

Mode d'utilisation:

Code :
1
2
3
4
Sub CreateMemoNotes() 
  SendNotesMail Me!txtSubject, Me!txtAttachment, Me!txtTo, _
                Me!txtCC, Me!txtCCC, Me!txtMessage, False 
End Sub
Déclaration de l'API (A placer en haut de module) :
Code :
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
Private Declare Function GetOpenFileName Lib _
"comdlg32.dll" Alias "GetOpenFileNameA" _
(pOpenfilename As OPENFILENAME) As Long 
 
Private Type OPENFILENAME 
  lStructSize As Long 
  hwndOwner As Long 
  hInstance As Long 
  lpstrFilter As String 
  lpstrCustomFilter As String 
  nMaxCustFilter As Long 
  nFilterIndex As Long 
  lpstrFile As String 
  nMaxFile As Long 
  lpstrFileTitle As String 
  nMaxFileTitle As Long 
  lpstrInitialDir As String 
  lpstrTitle As String 
  flags As Long 
  nFileOffset As Integer 
  nFileExtension As Integer 
  lpstrDefExt As String 
  lCustData As Long 
  lpfnHook As Long 
  lpTemplateName As String 
End Type 
 
Private Const OFN_READONLY = &H1 
Private Const OFN_OVERWRITEPROMPT = &H2 
Private Const OFN_HIDEREADONLY = &H4 
Private Const OFN_NOCHANGEDIR = &H8 
Private Const OFN_SHOWHELP = &H10 
Private Const OFN_ENABLEHOOK = &H20 
Private Const OFN_ENABLETEMPLATE = &H40 
Private Const OFN_ENABLETEMPLATEHANDLE = &H80 
Private Const OFN_NOVALIDATE = &H100 
Private Const OFN_ALLOWMULTISELECT = &H200 
Private Const OFN_EXTENSIONDIFFERENT = &H400 
Private Const OFN_PATHMUSTEXIST = &H800 
Private Const OFN_FILEMUSTEXIST = &H1000 
Private Const OFN_CREATEPROMPT = &H2000 
Private Const OFN_SHAREAWARE = &H4000 
Private Const OFN_NOREADONLYRETURN = &H8000 
Private Const OFN_NOTESTFILECREATE = &H10000 
Private Const OFN_NONETWORKBUTTON = &H20000 
Private Const OFN_NOLONGNAMES = &H40000 
Private Const OFN_EXPLORER = &H80000 
Private Const OFN_NODEREFERENCELINKS = &H100000 
Private Const OFN_LONGNAMES = &H200000
Fonction d'affichage de la boîte de dialogue des fichiers à joindre
Code :
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
Public Function fnctGetAttachedFiles(ByVal InitialDir _
 As String, ByVal Extensions As String, _
        ByVal ApplicationName As String) As String 
 
Const MIN_PATH As Integer = 260 
Const MAX_PATH As Integer = 8192 
Dim oOFN As OPENFILENAME 
Dim lReturn As Long 
Dim sFilter As String 
Dim sAttachmentString As String 
Dim aApplications() As String 
Dim aExtensions() As String 
Dim I As Integer 
 
    aApplications = Split(ApplicationName, ";") 
    aExtensions = Split(Extensions, ";") 
 
    For I = LBound(aApplications) To UBound(aApplications) 
        sFilter = sFilter & "Fichiers " & aApplications(I) & _
          vbNullChar & aExtensions(I) & vbNullChar 
    Next 
 
    With oOFN 
    .lStructSize = Len(oOFN) 
    .hwndOwner = Application.hWndAccessApp 
    .lpstrFile = Extensions 
    .lpstrFilter = sFilter 
    .nFilterIndex = 1 
    .lpstrFile = String(MIN_PATH, 0) 
    .flags = OFN_LONGNAMES Or OFN_HIDEREADONLY _
          Or OFN_ALLOWMULTISELECT 
    .nMaxFile = IIf((.flags And OFN_ALLOWMULTISELECT) = _
         OFN_ALLOWMULTISELECT, MAX_PATH, MIN_PATH - 1) 
    .lpstrFileTitle = .lpstrFile 
    .nMaxFileTitle = .nMaxFile 
    .lpstrInitialDir = IIf(Len(InitialDir) = 0, _
          Left(Application.CurrentProject.Path, 3), InitialDir) 
    .lpstrTitle = "Sélection de fichiers en pièces jointes" 
    End With 
    lReturn = GetOpenFileName(oOFN) 
 
    sAttachmentString = oOFN.lpstrFile 
    If InStr(1, sAttachmentString, vbNullChar) Then 
      sAttachmentString = Trim(Left(sAttachmentString, _
       InStr(1, sAttachmentString, vbNullChar) - 1)) 
    End If 
 
    fnctGetAttachedFiles = sAttachmentString 
 
End Function
Code à affecter au bouton Parcourir...
Code :
1
2
3
4
5
6
7
8
9
10
11
Sub ShowFileDialog() 
Dim sAttachmentString As String 
 
  sAttachmentString = fnctGetAttachedFiles("D:\Data", _
       "*.doc;*.xls;*.mdb;*.txt", "Word;Excel;Access;Notepad") 
  If Len(sAttachmentString) > 0 Then 
    Me!txtAttachment = sAttachmentString 
  Else 
    Me!txtAttachment = vbnulstring 
  End If 
End Sub
Debutant10 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 10/08/2011, 17h13   #7
Expert Confirmé
 
Avatar de Godzestla
 
Homme
Chercheur de bonheur
Inscription : août 2007
Messages : 2 255
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 47
Localisation : Belgique

Informations professionnelles :
Activité : Chercheur de bonheur
Secteur : Industrie

Informations forums :
Inscription : août 2007
Messages : 2 255
Points : 2 979
Points : 2 979
Bonjour,

j'utilise Lotus notes via access et excel, mais n'ai jamais ajouté plus d'une pièce à la fois.

Ce code est farfelu (ton code).
Code :
1
2
3
4
5
6
        'Prend en compte les pièces jointes
    If projet 1 and projet 2 <> "" Then
        Set AttachME = MailDoc.CREATERICHTEXTITEM("projet 1 and projet 2")
        Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", projet 1 and projet 2, "projet 1 and projet 2")
        MailDoc.CREATERICHTEXTITEM ("projet 1 and projet 2")
    End If
Notes ne peut pas comprendre cette tentative de combinaison de 2 attachement.

Je tenterais à ta place l'exécution d'un groupe de code, comme celui-ci, à adapter à tes besoins.

Code :
1
2
3
4
5
6
7
8
9
10
11
12
 
    Dim AttachME1 As Object    'L'objet pièce jointe en RTF
    Dim AttachME2 As Object    'L'objet pièce jointe en RTF
    Dim EmbedObj1 As Object    'L'objet incorporé
    Dim EmbedObj2 As Object    'L'objet incorporé
 
'...
 
        Set AttachME1 = MailDoc.CREATERICHTEXTITEM("Attachment")
        Set EmbedObj1 = AttachME.EMBEDOBJECT(1454, "",  Ton_PDF_1, "Attachment")
        Set AttachME2 = MailDoc.CREATERICHTEXTITEM("Attachment")
        Set EmbedObj2 = AttachME.EMBEDOBJECT(1454, "", Ton_PDF_2, "Attachment")
Bonne chance
__________________
(\ _ /) Cordialement G@dz
(='.'=)

(")-(") Vous avez des neurones. Sollicitez-les. . Si vous êtes aidé, pensez à Voter.
Godzestla est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 10/08/2011, 21h06   #8
Futur Membre du Club
 
Inscription : janvier 2008
Messages : 304
Détails du profil
Informations forums :
Inscription : janvier 2008
Messages : 304
Points : 18
Points : 18
Par défaut comment faire pour visualiser le contenu du mail avant envoi

Tou d'abord MERCI godzelta j'y vois un peu plus clair,

Pourriez vous me dire les étapes à faire ?

Exemple :

faut-il dans un 1 er tps transformer mes 2 états en pdf ? si oui avec quel code ?

Ensuite comment faire pour visualiser le contenu du mail avant envoi ?

MERCI
Debutant10 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 11/08/2011, 08h59   #9
Expert Confirmé
 
Avatar de Godzestla
 
Homme
Chercheur de bonheur
Inscription : août 2007
Messages : 2 255
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 47
Localisation : Belgique

Informations professionnelles :
Activité : Chercheur de bonheur
Secteur : Industrie

Informations forums :
Inscription : août 2007
Messages : 2 255
Points : 2 979
Points : 2 979
Citation:
Envoyé par Debutant10 Voir le message

faut-il dans un 1 er tps transformer mes 2 états en pdf ? si oui avec quel code ?
Présentement mon frêre.
Je ne dispose pas de AC-2007, mais la création de PDF y est native.
Donc en cherchant dans le forum, tu devrais trouver ta réponse aisément.

A ta place, je ferais la fusion des 2 PDF en 1 seul après création pour n'avaoir qu'1 seul attachement. (il y a des tas d'utilitaires gratuits pour cela, si en natif tu ne peux faire cela. pour lancer des utilitaires externes, regarde ce post :

Citation:
Ensuite comment faire pour visualiser le contenu du mail avant envoi ?
Je n'ai jamais réussi à le faire, malheureusement. les difficultés sont à la hauteur du manque de documentation.
Notes ne fonctionne pas vraiment comme Outlook.
J'utilise la zone bcc en mettant mon propre email pour recevoir ce mail en copie.

Regarde ci-dessous la procédure que j'utilise.

Code :
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
 
'Envoi d'un mail avec Lotus Notes
'Subject : sujet du mail
'Attachment : nom d'une pièce jointe
'Recipient : adresse e-mail du destinataire principal
'ccRecipient : destinataire en copie
'bccRecipient : destinataire en copie invisible
'BodyText : corps du mail
'SaveIt : mettre à True pour que le mail soit sauvegardé
'Password : mot de passe
 
'call SendNotesMail("Subject", "mon_attachement", "mon_email", "ccrecepient", "bccrecipient", "bodytext", FALSE, "password")
' Attention Probleme si SaveIt = True : Erreur au send. Contourner en mettant sender en BCC.
' Password ne marche pas. Ligne en commentaire
 
Public Sub SendNotesMail(ByVal Notes_Dbname As String, ByVal Sender As String, _
                         ByVal Subject As String, ByVal Attachment As String, _
                         ByVal Recipient As String, ByVal CCRecipient As String, _
                         ByVal BCCRecipient As String, ByVal Bodytext As String, _
                         ByVal SaveIt As Boolean, ByVal Password As String)
 
    Dim Maildb As Object      'La base des mails
    Dim UserName As String    'Le nom d'utilisateur
    Dim MailDbName As String  'Le nom de la base des mails
    Dim MailDoc As Object     'Le mail
    Dim AttachME As Object    'L'objet pièce jointe en RTF
    Dim Session As Object     'La session Notes
    Dim EmbedObj As Object    'L'objet incorporé
    Dim Ini_File As String    'Full Name of ini File
    Dim recip()  As String    'Tableau des destinataires
    Dim length   As Long
    Dim idx      As Long
    Dim off_in   As Long
    Dim off_out  As Long
    Dim temp_rec As String
    Dim Start As Long
 
 
 
    'Retrieve Parms from Ini
 
    'Crée une session notes
    Set Session = CreateObject("Notes.NotesSession")
 
    '*** Cette ligne est réservée aux versions 5.x et supérieur : ***
    'Session.Initialize (Password)
 
    'Notes Database Name
    MailDbName = Notes_Dbname
 
    'Ouvre la base des mails
    Set Maildb = Session.GETDATABASE("", MailDbName)
    If Not Maildb.IsOpen Then Maildb.OPENMAIL
 
    'Paramètre le mail à envoyer
  'Il est possible d'indiquer à Lotus Notes plusieurs destinataires en affectant un tableau de type Variant à la propriété sendto :
 
 
    'Split recipient list
    recip = Split(Recipient, ",")
    Set MailDoc = Maildb.CREATEDOCUMENT
    MailDoc.Form = "Memo"
    MailDoc.sendto = recip()
    MailDoc.CopyTo = CCRecipient
    MailDoc.BlindCopyTo = BCCRecipient
    MailDoc.Subject = Subject
    MailDoc.Body = Bodytext & " " & Sender
    MailDoc.SAVEMESSAGEONSEND = SaveIt
 
    'Prend en compte les pièces jointes
    If Attachment <> "" Then
        Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
        Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
 
    End If
 
    'Envoie le mail
    MailDoc.PostedDate = Now()
    MailDoc.SEND 0, recip
 
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set AttachME = Nothing
    Set Session = Nothing
    Set EmbedObj = Nothing
 
 
End Sub
__________________
(\ _ /) Cordialement G@dz
(='.'=)

(")-(") Vous avez des neurones. Sollicitez-les. . Si vous êtes aidé, pensez à Voter.
Godzestla est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 11/08/2011, 21h22   #10
Futur Membre du Club
 
Inscription : janvier 2008
Messages : 304
Détails du profil
Informations forums :
Inscription : janvier 2008
Messages : 304
Points : 18
Points : 18
Par défaut Faire un mail = une pièce jointe

Merci Godzelta pour l'info je vais faire simple j'opte pour faire un mail = une pièce jointe pour cela j'ai besoin que vous m'expliquer svp :


A quel moment du code puis-je choisir plusieurs destinataires ?
(exemple dans une liste ou autre ? )

comment fonctionne Dim recip() As String la variable dans votre méthode MailDoc.sendto = recip() y-a-t-il un lien avec...une table .?

Et quel moment du code puis-je déclarer et mettre en pièce jointe mon état "projet 1"


Code :
1
2
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
        Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "projet 1")
c'est correct mon placement projet 1 dans le code ? merci pour votre aide
Debutant10 est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 12/08/2011, 09h34   #11
Expert Confirmé
 
Avatar de Godzestla
 
Homme
Chercheur de bonheur
Inscription : août 2007
Messages : 2 255
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 47
Localisation : Belgique

Informations professionnelles :
Activité : Chercheur de bonheur
Secteur : Industrie

Informations forums :
Inscription : août 2007
Messages : 2 255
Points : 2 979
Points : 2 979
Salut,

je répond très vite car pas de temps.

Prend le temps de regarder mon code et d'essayer de le comprendre. Il n'est pas difficile et n'est d'ailleurs pas de moi 'il est très proche du tien mais juste 1 peu adapté).

Récip est une table. Je passe le/les destinataire(s) à la fonction via la parm Recipient. Recipient contient 1 ou plusieurs destinataire séparés par des virgules (syntaxe standard). Notes ne supportant pas cette syntaxe, l'instruction split eclate le string sur base des séparateurs (virgules) et donne à Notes une table avec le/les destinataires, ce que Notes attend comme type de parametre. La même technique est à appliquer à CC et BCC si besoin est.

Pour ton attachement, c'est faux je crois.

Le dernier parametre doit rester "Attachment", mais le premier est une variable qui contient le Fullname de ton attahcment.

Je passe donc via la variable Attachment le Fullname de l'attachement à joindre.

J'espère avoir répondu à tes questions.
__________________
(\ _ /) Cordialement G@dz
(='.'=)

(")-(") Vous avez des neurones. Sollicitez-les. . Si vous êtes aidé, pensez à Voter.
Godzestla est déconnecté   Envoyer un message privé Réponse avec citation 10
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 12h49.


 
 
 
 
Partenaires

Hébergement Web