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

Macros et VBA Excel Discussion :

Envoyer par mail mon fichier modifié


Sujet :

Macros et VBA Excel

  1. #21
    Membre du Club
    Profil pro
    Inscrit en
    Août 2007
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 141
    Points : 40
    Points
    40
    Par défaut
    Super ! Merci !

    Maintenant ça fonctionne ! (presque... )

    Voici mon code modifié :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    'Send the document
        dest = Sheets("MACRO").Range("A1") & ", " & Sheets("MACRO").Range("A2")
        monTab = Split(dest, ",")
        MailDoc.Send 0, monTab()
        MailDoc.PostedDate = Now()
    Pour le presque... C'est que je voudrais automatiser avec auto_open mais que si je fais cette modification, mon fichier envoyé contient la macro auto_open et la macro se lance donc à l'ouverture du fichier...

  2. #22
    Membre émérite Avatar de Godzestla
    Homme Profil pro
    Chercheur de bonheur
    Inscrit en
    Août 2007
    Messages
    2 392
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : Belgique

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

    Informations forums :
    Inscription : Août 2007
    Messages : 2 392
    Points : 2 985
    Points
    2 985
    Par défaut
    Donc ca fonctionne. Enfin.

    Pour ta deuxième question, je te propose de cloturer cette demande en mettant résolu et de créer une nouvelle avec ton nouveau problème, qui n'a rien à voir.

  3. #23
    Membre du Club
    Profil pro
    Inscrit en
    Août 2007
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 141
    Points : 40
    Points
    40
    Par défaut
    Je réouvre parce que je viens de me rendre compte qu'en lançant ma macro sur un autre PC, le fichier joint n'apparaît plus dans mon mail...

    Je pense que ça doit venir du code suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    Attachment = ThisWorkbook.FullName
        If Attachment <> "" Then
            Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
            Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
            MailDoc.CREATERICHTEXTITEM ("Attachment")
        End If

  4. #24
    Membre émérite Avatar de Godzestla
    Homme Profil pro
    Chercheur de bonheur
    Inscrit en
    Août 2007
    Messages
    2 392
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : Belgique

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

    Informations forums :
    Inscription : Août 2007
    Messages : 2 392
    Points : 2 985
    Points
    2 985
    Par défaut
    Demande au Debug ce que vaut Attachment.

  5. #25
    Membre du Club
    Profil pro
    Inscrit en
    Août 2007
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 141
    Points : 40
    Points
    40
    Par défaut
    Je sais pas trop comment on met en place le debug alors j'ai mis en place un espion qui me dit que la valeur Attachement est vide...

  6. #26
    Membre du Club
    Profil pro
    Inscrit en
    Août 2007
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 141
    Points : 40
    Points
    40
    Par défaut
    Non, non, je n'ai rien dit, il me dit que Attachement est sur C:\Documents and Settings\moi\Desktop\Quota Alerte Mail.xls

  7. #27
    Membre confirmé Avatar de drakkar_agfa
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    618
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : Canada

    Informations forums :
    Inscription : Septembre 2008
    Messages : 618
    Points : 638
    Points
    638
    Par défaut
    Es-tu certain que
    C:\Documents and Settings\moi\Desktop\Quota Alerte Mail.xls
    existe sur l'autre PC? Est-ce que le chemin est différent? (Moi?)

  8. #28
    Membre du Club
    Profil pro
    Inscrit en
    Août 2007
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 141
    Points : 40
    Points
    40
    Par défaut
    Je suis contient que ça n'est pas très clair, désolé mais je n'arrive pas à faire autrement.
    En gras dans le texte ce que me renvoie Attachment.
    Tout à l'air d'être bon, mais bien sur, ça ne fonctionne pas.
    Si un PC, ça fonctionne mais pas sur l'autre
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Sheets("Parms").Range("A1") = 0
           newname = "C:\Quota Alerte Mail.xls" => newname = "C:\Quota Alerte Mail.xls"
        ThisWorkbook.SaveCopyAs Filename:=newname => newname = "C:\Quota Alerte Mail.xls"
        Sheets("Parms").Range("A1") = 1
        Attachment = newname => newname = "C:\Quota Alerte Mail.xls"
            
        Attachment = ThisWorkbook.FullName => newname = "C:\Quota Alerte Mail.xls"
        If Attachment <> "" Then  => newname = "C:\Quota Alerte Mail.xls"
            Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment") => ne renvoie rien
            Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")  => newname = "C:\Quota Alerte Mail.xls" => ne renvoie rien
            MailDoc.CREATERICHTEXTITEM ("Attachment") => ne renvoie rien
        End If

  9. #29
    Membre confirmé Avatar de drakkar_agfa
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    618
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : Canada

    Informations forums :
    Inscription : Septembre 2008
    Messages : 618
    Points : 638
    Points
    638
    Par défaut
    Est-ce possible de mettre ton code dans la balise.
    Et l'arranger avec des commentaires parce que pour l'instant ça donne ceci et ce n'est pas très clair.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Sheets("Parms").Range("A1") = 0
    newname = "C:\Quota Alerte Mail.xls" => newname = "C:\Quota Alerte Mail.xls"
    ThisWorkbook.SaveCopyAs Filename:=newname => newname = "C:\Quota Alerte Mail.xls"
    Sheets("Parms").Range("A1") = 1
    Attachment = newname [/b]=> newname = "C:\Quota Alerte Mail.xls"[/b]
     
    Attachment = ThisWorkbook.FullName => newname = "C:\Quota Alerte Mail.xls"
    If Attachment <> "" Then [/b]newname = "C:\Quota Alerte Mail.xls"[/b]
    Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment") => ne renvoie rien
    Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment") => newname = "C:\Quota Alerte Mail.xls"[/b] => ne renvoie rien
    MailDoc.CREATERICHTEXTITEM ("Attachment") => ne renvoie rien
    End If
    Merci

  10. #30
    Membre du Club
    Profil pro
    Inscrit en
    Août 2007
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 141
    Points : 40
    Points
    40
    Par défaut
    Je suis contient que ça n'est pas très clair, désolé mais je n'arrive pas à faire autrement.
    En gras dans le texte ce que me renvoie Attachment.
    Tout à l'air d'être bon, mais bien sur, ça ne fonctionne pas.
    Si un PC, ça fonctionne mais pas sur l'autre
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    Sheets("Parms").Range("A1") = 0
           newname = "C:\Quota Alerte Mail.xls" => newname = "C:\Quota Alerte Mail.xls"
        ThisWorkbook.SaveCopyAs Filename:=newname => newname = "C:\Quota Alerte Mail.xls"
        Sheets("Parms").Range("A1") = 1
        Attachment = newname => newname = "C:\Quota Alerte Mail.xls"
            
        Attachment = ThisWorkbook.FullName => newname = "C:\Quota Alerte Mail.xls"
        If Attachment <> "" Then  => newname = "C:\Quota Alerte Mail.xls"
            Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment") => ne renvoie rien
            Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")  => newname = "C:\Quota Alerte Mail.xls" => ne renvoie rien
            MailDoc.CREATERICHTEXTITEM ("Attachment") => ne renvoie rien
        End If

  11. #31
    Membre confirmé Avatar de drakkar_agfa
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    618
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : Canada

    Informations forums :
    Inscription : Septembre 2008
    Messages : 618
    Points : 638
    Points
    638
    Par défaut
    J'ai ceci
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
        newname = "C:\Quota Alerte Mail.xls" '>= newname = "C:\Quota Alerte Mail.xls"
        ThisWorkbook.SaveCopyAs Filename:=newname '>= newname = "C:\Quota Alerte Mail.xls"
        attachment = newname '>= newname = "C:\Quota Alerte Mail.xls"
     
        attachment = ThisWorkbook.FullName '>= newname = "C:\Quota Alerte Mail.xls"
        If attachment <> "" Then  '=> newname = "C:\Quota Alerte Mail.xls"
            Set attachme = MailDoc.CREATERICHTEXTITEM("Attachment") '=> ne renvoie rien
            Set EmbedObj = attachme.EMBEDOBJECT(1454, "", attachment, "Attachment")  '=> newname = "C:\Quota Alerte Mail.xls" => ne renvoie rien
            MailDoc.CREATERICHTEXTITEM ("Attachment") '=> ne renvoie rien
        End If
    Est-ce que tu peux nous donner tout ton code?
    Est-ce que attachment, attachme et MailDoc sont bien déclarés?
    Essais avec Option Explicit (Clin d'oeil à Godzestla)
    Est-ce que (si tu utilises notes) l'autre PC à bien notes?

  12. #32
    Membre émérite Avatar de Godzestla
    Homme Profil pro
    Chercheur de bonheur
    Inscrit en
    Août 2007
    Messages
    2 392
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : Belgique

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

    Informations forums :
    Inscription : Août 2007
    Messages : 2 392
    Points : 2 985
    Points
    2 985
    Par défaut
    Citation Envoyé par drakkar_agfa Voir le message
    J'ai ceci
    Essais avec Option Explicit (Clin d'oeil à Godzestla)
    Bien vu drakkar_agfa

    He mattwarend,
    tu es de nouveau dans la choucroute.
    Il y a une ligne en trop dans le code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
       attachment = ThisWorkbook.FullName '>= newname = "C:\Quota Alerte Mail.xls"
    A supprimer sinon on envoi le fichier sans la modif pour auto_open
    (héh de nouveau très fatigué...)

    Pour info, dans ton autre post, je t'ai donné une solution qui semble juste à 15h23, mais tu as un peu foutu la chianli dedans. !!!

  13. #33
    Membre du Club
    Profil pro
    Inscrit en
    Août 2007
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 141
    Points : 40
    Points
    40
    Par défaut
    Salut !

    Merci pour votre aide ! C'est cool !
    Voici mon code complet :

    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
     
    Sub Sendmail()
     
        Cells.Select
        Selection.ClearContents
        Range("A1").Select
     
        ChDir "C:\Documents and Settings\admincot\Desktop"
        Workbooks.OpenText Filename:="\\eufrhqfs01wp\QUOTALOG\Usage.txt", Origin:= _
            xlMSDOS, StartRow:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote _
            , ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=True, Comma:= _
            False, Space:=False, Other:=False, FieldInfo:=Array(1, 1), _
            TrailingMinusNumbers:=True
     
    ActiveWorkbook.Save
     
    On Error Resume Next
     
     
        Dim Maildb As Object 'The mail database
        Dim UserName As String 'The current users notes name
        Dim MailDbName As String 'THe current users notes mail database name
        Dim MailDoc As Object 'The mail document itself
        Dim AttachME As Object 'The attachment richtextfile object
        Dim Session As Object 'The notes session
        Dim EmbedObj As Object 'The embedded object (Attachment)
        Dim dest As String
        Dim monTab() As String
     
     
        Set Session = CreateObject("Notes.NotesSession")
        UserName = Session.UserName
        MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
        'Open the mail database in notes
        Set Maildb = Session.GetDatabase("", MailDbName)
         If Maildb.IsOpen = True Then
              'Already open for mail
         Else
     
         Maildb.OPENMAIL
     
         End If
        'Set up the new mail document
        Set MailDoc = Maildb.CreateDocument
        MailDoc.Form = "Memo"
        MailDoc.Subject = "Envoi Automatique Alerte Quota FS01"
        MailDoc.body = "Alerte de Quota sur FS01"
        MailDoc.SAVEMESSAGEONSEND = saveit
     
        Sheets("Parms").Range("A1") = 0
        newname = "C:\Quota Alerte Mail"
        Sheets("Parms").Range("A1") = 1
        Attachment = newname
     
          If Attachment <> "" Then
            Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
            Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
            MailDoc.CREATERICHTEXTITEM ("Attachment")
        End If
     
     
     
        'Send the document
        dest = Sheets("MACRO").Range("A1") & ", " & Sheets("MACRO").Range("A2")
        monTab = Split(dest, ",")
        MailDoc.Send 0, monTab()
        MailDoc.PostedDate = Now()
     
        'Clean Up
        Set Maildb = Nothing
        Set MailDoc = Nothing
        Set AttachME = Nothing
        Set Session = Nothing
        Set EmbedObj = Nothing
     
        Excel.Application.Quit
        Application.DisplayAlerts = False
     
    End Sub
    drakkar_agfa, pour répondre à tes questions :
    attachment, attachme et MailDoc semblent bien déclarés.
    Option Explicit, je dois le mettre en début de code (ça sert à quoi ? Je débute...)
    Les deux PC disposent bien de Notes.

    Godzestla, j'ai enlevé la ligne que tu m'as indiqué. Je vais voir ta réponse dans l'autre post.

    Merci à tous les deux !

  14. #34
    Membre émérite Avatar de Godzestla
    Homme Profil pro
    Chercheur de bonheur
    Inscrit en
    Août 2007
    Messages
    2 392
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 59
    Localisation : Belgique

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

    Informations forums :
    Inscription : Août 2007
    Messages : 2 392
    Points : 2 985
    Points
    2 985
    Par défaut
    Citation Envoyé par mattwarend Voir le message
    Salut !

    Godzestla, j'ai enlevé la ligne que tu m'as indiqué. Je vais voir ta réponse dans l'autre post.
    Oui parce que là, c'est totalement foireux.....

  15. #35
    Membre confirmé Avatar de drakkar_agfa
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    618
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : Canada

    Informations forums :
    Inscription : Septembre 2008
    Messages : 618
    Points : 638
    Points
    638
    Par défaut
    Essais avec ceci

    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
    Sub testEnvoyer()
        Dim sDestinataire As String
        Dim sTitre As String
        Dim sCorp As String
        Dim sFile As String
     
        sDestinataire = ??????
        sTitre = ?????
        sCorp = ?????
        sFile = ?????
        Call EnvoyerFichier(sDestinataire, sTitre, sCorp, sFile)
    End Sub
    Public Sub EnvoyerFichier(ByVal MailDestinataire As String, ByVal Sujet As String, ByVal CorpsMessage As String, ByVal attachment As String)
     
    'On Error GoTo Gerreur
     
    'Dim session As Domino.NotesSession
    Dim Session As Object
    Dim db As Object
    Dim doc As Object
    Dim attachme As Object
    Dim EmbedObj As Object
    Set Session = CreateObject("notes.notessession")
    Set db = Session.GETDATABASE("", "")
    Call db.OPENMAIL
     
    Set doc = db.CREATEDOCUMENT
     
    With doc
        .Form = "Memo"
        .AltFrom = Session.UserName
        .BGTableColor = "bg_4"
        .logo = "StdNotesLtr17"
        .ReturnReceipt = 0
        .UseApplet = "True"
        .DefaultMailSaveOptions = 1
        .Encrypt = 0
        .Sign = 0
        .EnterSendto = MailDestinataire
        .SendTo = MailDestinataire
        .CopyTo = MailCopy
        .Subject = Sujet
        .body = CorpsMessage
        .from = Session.COMMONUSERNAME
        .posteddate = Now
        .SaveMessageOnSend = True
    End With
    If attachement <> "" Then
        Set attachme = doc.CREATERICHTEXTITEM("attachement")
        Set EmbedObj = attachme.EMBEDOBJECT(1454, "", attachment, "attachement")
        doc.CREATERICHTEXTITEM ("attachment")
    End If
    Call doc.SEND(False)
     
    Exit Sub
    Gerreur:
    MsgBox Err.Number & " : " & Err.Description, vbCritical, "Erreur"
     
    End Sub
    Utilise la première fonction pour trouver le destinataire, le titre, le corp et la pièce jointe. Le reste, le bout pour envoyer le message, fonctionne.

    Test avec des données connues genre

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    Sub testEnvoyer()
        Dim sDestinataire As String
        Dim sTitre As String
        Dim sCorp As String
        Dim sFile As String
     
        sDestinataire = "Moi(La tienne)"
        sTitre = "Test du Titre"
        sCorp = "Test du corp"
        sFile = "C:(ton chemin)MyFile.xls"
        Call EnvoyerFichier(sDestinataire, sTitre, sCorp, sFile)
    End Sub
    Et si ça fonctionne, essais avec tes techniques pour sauvegarder le fichier, trouver son nom, utiliser tes ranges.
    Comme ca, tu verras si l'envoye en tant que tel fonctionne.

  16. #36
    Membre du Club
    Profil pro
    Inscrit en
    Août 2007
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 141
    Points : 40
    Points
    40
    Par défaut
    Salut drakkar_agfa,

    Merci, merci !

    Je teste dès demain au taf.
    En fait je fais un copié collé des deux instructions que tu m'as donné et je lance la macro ?

  17. #37
    Membre confirmé Avatar de drakkar_agfa
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    618
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : Canada

    Informations forums :
    Inscription : Septembre 2008
    Messages : 618
    Points : 638
    Points
    638
    Par défaut
    Oui,
    Mais oublis pas de changer dans la sub de lancement le destinataire et le fichier à envoyer (le titre et le corp ça ne dérange pas vraiment pour le test.)

  18. #38
    Membre du Club
    Profil pro
    Inscrit en
    Août 2007
    Messages
    141
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2007
    Messages : 141
    Points : 40
    Points
    40
    Par défaut
    Salut !

    L'envoi fonctionne toujours mais maintenant, pas de pièce jointe ni sur un PC ni sur l'autre :

    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
     
    Sub testEnvoyer()
        Dim sDestinataire As String
        Dim sTitre As String
        Dim sCorp As String
        Dim sFile As String
     
        sDestinataire = "monadresse@moi.com"
        sTitre = "Test du Titre"
        sCorp = "Test du corp"
        sFile = "C:\Nouveau dossier\Quota Alerte Mail.xls"
     
        Call EnvoyerFichier(sDestinataire, sTitre, sCorp, sFile)
    End Sub
    Public Sub EnvoyerFichier(ByVal MailDestinataire As String, ByVal Sujet As String, ByVal CorpsMessage As String, ByVal attachment As String)
     
    'On Error GoTo Gerreur
     
    'Dim session As Domino.NotesSession
    Dim Session As Object
    Dim db As Object
    Dim doc As Object
    Dim attachme As Object
    Dim EmbedObj As Object
    Set Session = CreateObject("notes.notessession")
    Set db = Session.GETDATABASE("", "")
    Call db.OPENMAIL
     
    Set doc = db.CREATEDOCUMENT
     
    With doc
        .Form = "Memo"
        .AltFrom = Session.UserName
        .BGTableColor = "bg_4"
        .logo = "StdNotesLtr17"
        .ReturnReceipt = 0
        .UseApplet = "True"
        .DefaultMailSaveOptions = 1
        .Encrypt = 0
        .Sign = 0
        .EnterSendto = MailDestinataire
        .SendTo = MailDestinataire
        .CopyTo = MailCopy
        .Subject = Sujet
        .body = CorpsMessage
        .from = Session.COMMONUSERNAME
        .posteddate = Now
        .SaveMessageOnSend = True
    End With
    If attachement <> "" Then
        Set attachme = doc.CREATERICHTEXTITEM("attachement")
        Set EmbedObj = attachme.EMBEDOBJECT(1454, "", attachment, "attachement")
        doc.CREATERICHTEXTITEM ("attachment")
    End If
    Call doc.SEND(False)
     
    Exit Sub
    Gerreur:
    MsgBox Err.Number & " : " & Err.Description, vbCritical, "Erreur"
     
    End Sub
    J'ai vérifié la présence du fichier dans le répertoire, c'est OK.

    Sinon, pour résoudre définitivement mon problème, est-il possible plutôt que d'envoyer mon fichier en pièce jointe de modifier mon code pour seul le contenu des cellules renseignées soient mise dans le corps du message ?

  19. #39
    Membre éprouvé
    Avatar de JackOuYA
    Inscrit en
    Juin 2008
    Messages
    1 040
    Détails du profil
    Informations forums :
    Inscription : Juin 2008
    Messages : 1 040
    Points : 1 191
    Points
    1 191
    Par défaut
    Bonjour,

    je n'ai jamais envoyé de document avec notes... mais sans connaitre ses objets je ne vois pas le lien dans ton code entre le document envoyé et les piéces jointes ..:

    tu utilise 2 objets : attachme et EmbedObj, mais tu ne les "lies" nulle-part à ton objet doc.. envoyé... il doit manquer quelque-chose

  20. #40
    Membre confirmé Avatar de drakkar_agfa
    Profil pro
    Inscrit en
    Septembre 2008
    Messages
    618
    Détails du profil
    Informations personnelles :
    Âge : 37
    Localisation : Canada

    Informations forums :
    Inscription : Septembre 2008
    Messages : 618
    Points : 638
    Points
    638
    Par défaut
    Oups, un erreur de ma part, regarde ceci!

    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
    option explicit
    
    Sub testEnvoyer()
        Dim sDestinataire As String
        Dim sTitre As String
        Dim sCorp As String
        Dim sFile As String
        
        sDestinataire = "monadresse@moi.com"
        sTitre = "Test du Titre"
        sCorp = "Test du corp"
        sFile = "C:\Nouveau dossier\Quota Alerte Mail.xls"
     
        Call EnvoyerFichier(sDestinataire, sTitre, sCorp, sFile)
    End Sub
    Public Sub EnvoyerFichier(ByVal MailDestinataire As String, ByVal Sujet As String, ByVal CorpsMessage As String, ByVal attachment As String)
     
    'On Error GoTo Gerreur
     
    'Dim session As Domino.NotesSession
    Dim Session As Object
    Dim db As Object
    Dim doc As Object
    Dim attachme As Object
    Dim EmbedObj As Object
    Set Session = CreateObject("notes.notessession")
    Set db = Session.GETDATABASE("", "")
    Call db.OPENMAIL
     
    Set doc = db.CREATEDOCUMENT
     
    With doc
        .Form = "Memo"
        .AltFrom = Session.UserName
        .BGTableColor = "bg_4"
        .logo = "StdNotesLtr17"
        .ReturnReceipt = 0
        .UseApplet = "True"
        .DefaultMailSaveOptions = 1
        .Encrypt = 0
        .Sign = 0
        .EnterSendto = MailDestinataire
        .SendTo = MailDestinataire
        .CopyTo = MailCopy
        .Subject = Sujet
        .body = CorpsMessage
        .from = Session.COMMONUSERNAME
        .posteddate = Now
        .SaveMessageOnSend = True
    End With
    If attachment <> "" Then
        Set attachme = doc.CREATERICHTEXTITEM("attachment")
        Set EmbedObj = attachme.EMBEDOBJECT(1454, "", attachment, "attachement")
        doc.CREATERICHTEXTITEM ("attachment")
    End If
    Call doc.SEND(False)
     
    Exit Sub
    Gerreur:
    MsgBox Err.Number & " : " & Err.Description, vbCritical, "Erreur"
        
    End Sub

Discussions similaires

  1. Envoyer par mail x fichiers excel qui viennent d'une table oracle
    Par philcphilc dans le forum Développement de jobs
    Réponses: 0
    Dernier message: 05/03/2014, 18h20
  2. Réponses: 2
    Dernier message: 03/09/2013, 16h04
  3. Comment modifier le corps d'un message envoyé par mail
    Par nico le noob dans le forum Langage
    Réponses: 8
    Dernier message: 15/05/2010, 18h00
  4. fichiers zipés à envoyer par mail
    Par jano_dave dans le forum Web & réseau
    Réponses: 6
    Dernier message: 19/09/2009, 02h08
  5. Réponses: 1
    Dernier message: 11/12/2008, 14h44

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