Problème d'envoi de Mail
Bonjour
j'aurai besoin d'aide sur une macro
quand j'envoie en email il y a 2 ligne qui ne fonctionne pas
DANS l'email que je recoi il y a a la place une ligne sans aucune donnée au lieu de récuperer le Checkbox1.value
Corps = CheckBox1.Value ' C EST LA LIGNE QUI NE MARCHE PAS
Corps = Corps & Chr(13) & Chr(10)
Corps = no_ligne - 2 ' C EST LA LIGNE QUI NE MARCHE PAS
je ne comprend pas pourquoi
CORDIALMENT
voici la macro
Private Sub CommandButton_Ajouter_Click()
Sheets("liste").Select
'Coloration des Labels en noir
Label_ordre.ForeColor = RGB(0, 0, 0)
Labe_atelier.ForeColor = RGB(0, 0, 0)
Label_Nom_de_L_assitante.ForeColor = RGB(0, 0, 0)
Label_article_origine.ForeColor = RGB(0, 0, 0)
Label_quantité_origine.ForeColor = RGB(0, 0, 0)
Label_article_fini.ForeColor = RGB(0, 0, 0)
Label_client_fini.ForeColor = RGB(0, 0, 0)
Labe_quantité_fini.ForeColor = RGB(0, 0, 0)
Label_date_expedition.ForeColor = RGB(0, 0, 0)
Label_visa_responsable.ForeColor = RGB(0, 0, 0)
'Contrôles de contenu
Dim no_ligne As Integer, civilite As String
no_ligne = Range("A65536").End(xlUp).Row + 1
'Insertion des valeurs sur la feuille
'sheets("liste").Select
Cells(no_ligne, 2) = MonthView_date.Value
Cells(no_ligne, 3) = ComboBox1_ordre.Value
Cells(no_ligne, 4) = ComboBox2_atelier.Value
Cells(no_ligne, 5) = TextBox_artilce_origine.Value
Cells(no_ligne, 6) = TextBox_quantité_origine.Value
Cells(no_ligne, 7) = TextBox_article_fini.Value
Cells(no_ligne, 8) = TextBox_client.Value
Cells(no_ligne, 9) = TextBox_quantité_fini.Value
Cells(no_ligne, 10) = CDate(TextBox_date_expedition.Value)
Cells(no_ligne, 25) = ComboBox_Assitante.Value
Cells(no_ligne, 11) = ComboBox_Qui.Value
Cells(no_ligne, 16) = "en cours"
Cells(no_ligne, 24) = TextBox_commentaire.Value
Cells(no_ligne, 26) = CheckBox1.Value
Cells(no_ligne, 1) = no_ligne - 2 ' compteur pour avoir la derniere ligne en haut
Dim MonOutlook As Object
Dim MonMessage As Object
Dim X As Object
On Error Resume Next
Set X = GetObject(, "Outlook.application")
If Err.Number <> 0 Then
MsgBox "Microsoft Outlook est fermer ouverture automatique"
Shell "Outlook"
Set MonOutlook = CreateObject("Outlook.Application")
' Et on crée un élément Outlook, qui sera un message E-Mail :
Set MonMessage = MonOutlook.CreateItem(0)
MonMessage.To = "Mon adress email "
MonMessage.Subject = " Ordre de traitement " + TextBox_article_fini.Value + " " + Sheets("liste").Cells(no_ligne, 14).Value '"sujet du message"
'MonMessage.body = ComboBox1_ordre.Value + vbCrLf + " pour " + ComboBox2_atelier.Value + " article origine " + TextBox_artilce_origine.Value + " vers l'article fini " + TextBox_article_fini.Value + " " + Sheets("liste").Cells(no_ligne, 14).Value + " quantité " + TextBox_quantité_fini.Value + " date " + TextBox_date_expedition.Value + " Contrôle Qualité " + Sheets("liste").Cells(no_ligne, 19).Value + " Commentaire " + TextBox_commentaire.Value '"Corp du message"
Corps = ComboBox1_ordre.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Pour : " + ComboBox2_atelier.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Article origine : " + TextBox_artilce_origine.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Vers l'article fini : " + TextBox_article_fini.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Désignation : " + Sheets("liste").Cells(no_ligne, 14).Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Client : " + TextBox_client.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Quantité : " + TextBox_quantité_fini.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Date d'expédition : " + TextBox_date_expedition.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Contrôle Qualité : " + Sheets("liste").Cells(no_ligne, 19).Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Commentaire : " + TextBox_commentaire.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Pour l'assistante : " + ComboBox_Assitante.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Traitement Retour Client : "
Corps = Corps & Chr(13) & Chr(10)
Corps = CheckBox1.Value ' C EST LA LIGNE QUI NE MARCHE PAS
Corps = Corps & Chr(13) & Chr(10)
Corps = no_ligne - 2 ' C EST LA LIGNE QUI NE MARCHE PAS
MonMessage.Body = Corps
MonMessage.ReadReceiptRequested = False 'Accusé de reception
MonMessage.Send
Set MonOutlook = Nothing ' On ferme !
ComboBox1_ordre.Value = ""
ComboBox2_atelier.Value = ""
ComboBox_Assitante.Value = ""
TextBox_artilce_origine.Value = ""
TextBox_quantité_origine.Value = ""
TextBox_article_fini.Value = ""
TextBox_client.Value = ""
TextBox_quantité_fini.Value = ""
TextBox_date_expedition.Value = ""
ComboBox_Qui.Value = ""
TextBox_commentaire.Value = ""
CheckBox1.Value = False
'ComboBox_Qui.ListIndex = -1
ActiveWorkbook.Save
Sheets("Menu").Select
Exit Sub
End If
Set MonOutlook = CreateObject("Outlook.Application")
' Et on crée un élément Outlook, qui sera un message E-Mail :
Set MonMessage = MonOutlook.CreateItem(0)
MonMessage.To = "mon adresse email "
MonMessage.Subject = " Ordre de traitement " + TextBox_article_fini.Value + " " + Sheets("liste").Cells(no_ligne, 14).Value '"sujet du message"
'MonMessage.Body = ComboBox1_ordre.Value + " pour " + ComboBox2_atelier.Value + " article origine " + TextBox_artilce_origine.Value + " vers l'article fini " + TextBox_article_fini.Value + " " + Sheets("liste").Cells(no_ligne, 14).Value + " quantité " + TextBox_quantité_fini.Value + " date " + TextBox_date_expedition.Value + " Contrôle Qualité " + Sheets("liste").Cells(no_ligne, 19).Value + " Commentaire " + TextBox_commentaire.Value '"Corp du message"
Corps = ComboBox1_ordre.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Pour : " + ComboBox2_atelier.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Article origine : " + TextBox_artilce_origine.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Vers l'article fini : " + TextBox_article_fini.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Désignation : " + Sheets("liste").Cells(no_ligne, 14).Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Client : " + TextBox_client.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Quantité : " + TextBox_quantité_fini.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Date d'expédition : " + TextBox_date_expedition.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Contrôle Qualité : " + Sheets("liste").Cells(no_ligne, 19).Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Commentaire : " + TextBox_commentaire.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Pour l'assistante : " + ComboBox_Assitante.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Traitement Retour Client : "
Corps = Corps & Chr(13) & Chr(10)
Corps = CheckBox1.Value ' C EST LA LIGNE QUI NE MARCHE PAS
Corps = Corps & Chr(13) & Chr(10)
Corps = no_ligne - 2 ' C EST LA LIGNE QUI NE MARCHE PAS
MonMessage.Body = Corps
MonMessage.ReadReceiptRequested = False 'Accusé de reception
MonMessage.Send
Set MonOutlook = Nothing ' On ferme !
'Après insertion, on remet les valeurs initiales
ComboBox1_ordre.Value = ""
ComboBox2_atelier.Value = ""
ComboBox_Assitante.Value = ""
TextBox_artilce_origine.Value = ""
TextBox_quantité_origine.Value = ""
TextBox_article_fini.Value = ""
TextBox_client.Value = ""
TextBox_quantité_fini.Value = ""
TextBox_date_expedition.Value = ""
ComboBox_Qui.Value = ""
CheckBox1.Value = False
ActiveWorkbook.Save
Sheets("Menu").Select
End Sub
Bonjour,
1) checkbox1.value te revoie une value (true ou false)
2) il me semble que tu oublies de rajouter corps & dans ces intructions.
donc le code devrait être (si tu souahites réellement voir apparaître true
or false
dans ton message
Corps = corps & CheckBox1.Value ' C EST LA LIGNE QUI NE MARCHE PAS
Corps = Corps & Chr(13) & Chr(10)
Corps =corps & no_ligne - 2 ' C EST LA LIGNE QUI NE MARCHE PAS
Bonjour
ceci fonctionne j'avais oublier le Corps &
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & CheckBox1.Value
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & no_ligne - 2
Mais si je fait cela
Corps = Corps & "Pour l'assistante : " + ComboBox_Assitante.Value ' celle ligne fonctionne
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Traitement Retour Client : " + CheckBox1.Value 'celle ligne ne fonctionne pas il n'affiche rien
Corps = Corps & Chr(13) & Chr(10)
Corps = Corps & "Numéro d'ordre : " + no_ligne - 2 'celle ligne ne fonctionne pas il n'affiche rien
je pense que le problème viens du + masi je ne comprend pas parce que la ligen avec COMBOX_assistante.value fonctionne
Cordialement
Bonjour,
remplace ton + par &
Bonjour
Edité titre du sujet. remplacé "Besoin d'aide"
Merci de lire ce lien qui t'aidera dans tes demandes et réponses sur ce forum --> Charte du forum
Amicalement