Probleme d'envoi mail

Laguich

XLDnaute Junior
Bonjour à tous,
J'ai une macro pour envoie de mail qui marche bien mais je n'arrive pas à l'adapter pour un nouveau cas.
Quelqu'un pourrait il m'aider?
Merci d'avance

J'ai fais les explications sur la feuille du fichier
 

Pièces jointes

  • pourforum.xlsm
    19.4 KB · Affichages: 24
  • pourforum.xlsm
    19.4 KB · Affichages: 30
  • pourforum.xlsm
    19.4 KB · Affichages: 30

Yaloo

XLDnaute Barbatruc
Re : Probleme d'envoi mail

Re,

Voici ta macro modifiée et simplifiée
VB:
Sub MAIL()
Dim MailAd As String, Msg As String, Subj As String, URLto As String
Dim moncorps As String
Dim c As Range, cc As Range
    'fin des déclarations  %0A POUR RETOUR LIGNE 'remplacer par  vbLf
ActiveWorkbook.Save
With Sheets(1)
  For Each c In .Range("M2:M" & .[M65536].End(3).Row)
    If c <> "" Then
      For Each cc In .Range("A2:A" & .[A65536].End(3).Row)
        If cc = c Then
          moncorps = moncorps & " " & cc(1, 2) & "--" & cc(1, 3) & "--" & cc(1, 4) & "--" & cc(1, 5) & "--" & cc(1, 6) & "%0A"
        End If
      Next
      Subj = "Commande de pièces à " & c & " pour " & [H2] & " du " & .[H4]
      Msg = "Voici une série de pièces à nous faire passer:" & "%0A" & "%0A" & moncorps & "%0A" & "Merci d'avance"
      URLto = "mailto:" & c(1, 2) & "?subject=" & Subj & "&body=" & Msg
      ActiveWorkbook.FollowHyperlink Address:=URLto
      moncorps = ""
    End If
  Next c
End With
End Sub

A+

Martial
 

Pièces jointes

  • pourforum.xlsm
    22.7 KB · Affichages: 57
  • pourforum.xlsm
    22.7 KB · Affichages: 30
  • pourforum.xlsm
    22.7 KB · Affichages: 29

Discussions similaires