Outlook avec pièces jointes

Bonjour au forum,

J'ai trouvé cette macro qui permet d’envoyer des pièces jointes définies dans le classeur, mais je rencontre 2 problèmes.

Sub envoi_PJ()
    ChDir ActiveWorkbook.Path
    répertoireAppli = ActiveWorkbook.Path   ' Penser à Outils/Références Outlook
    '---  Envoi par mail
    Dim olapp As Outlook.Application
    Sheets("destinataires").Select
    [A11].Select
    Do While Not IsEmpty(ActiveCell)
      MsgTo = MsgTo & ActiveCell & ";"
      ActiveCell.Offset(1, 0).Select
    Loop
    Dim msg As MailItem
    Set olapp = New Outlook.Application
    Set msg = olapp.CreateItem(olMailItem)
    msg.To = MsgTo
    msg.Subject = [A2]
    msg.Body = [A5] & Chr(13) & Chr(13) & Chr(13) & [A6] & Chr(13) & Chr(13) & Chr(13) & [A8].Value & Chr(13) & Chr(13)
    '-- pj
    [C8].Select
    Do While Not IsEmpty(ActiveCell)
      nf = ActiveWorkbook.Path & "\" & ActiveCell.Value
      msg.Attachments.Add Source:=nf
      ActiveCell.Offset(1, 0).Select
    Loop
    msg.Send
End Sub

1er problème : comment mettre un destinataire en Cc et un autre destinataire en CCi ? J'ai rajouté ces 2 codes

msg.CC = MsgCC et msg.BCC = Msg.BCC mais çà ne fontionnent pas. Qu'est-ce qui ne vas pas ?

Sub envoi_PJ()
    ChDir ActiveWorkbook.Path
    répertoireAppli = ActiveWorkbook.Path   ' Penser à Outils/Références Outlook
    '---  Envoi par mail
    Dim olapp As Outlook.Application
    Sheets("destinataires").Select
    [A11].Select
    Do While Not IsEmpty(ActiveCell)
      MsgTo = MsgTo & ActiveCell & ";"
      ActiveCell.Offset(1, 0).Select
    Loop
    Dim msg As MailItem
    Set olapp = New Outlook.Application
    Set msg = olapp.CreateItem(olMailItem)
    msg.To = MsgTo
    msg.CC = MsgCC
    msg.BCC = MsgBCC
    msg.Subject = [A2]
    msg.Body = [A5] & Chr(13) & Chr(13) & Chr(13) & [A6] & Chr(13) & Chr(13) & Chr(13) & [A8].Value & Chr(13) & Chr(13)
    '-- pj
    [C8].Select
    Do While Not IsEmpty(ActiveCell)
      nf = ActiveWorkbook.Path & "\" & ActiveCell.Value
      msg.Attachments.Add Source:=nf
      ActiveCell.Offset(1, 0).Select
    Loop
    msg.Display
End Sub

2è problème : comment ajouter une pièce jointe quelque soit le nom du fichier en pdf ?

Merci de votre aide.

Rechercher des sujets similaires à "outlook pieces jointes"