VBA - Envoyer un mail
Résolu
ChrisKad
Messages postés
7
Statut
Membre
-
f894009 Messages postés 17413 Statut Membre -
f894009 Messages postés 17413 Statut Membre -
Bonjour,
J'essaie d'envoyer par mail une partie du tcd via vba mais tout ce que ça fait c'est que ça me crée un fichier excel avec la partie que j'ai sélectionné, mais ça n'envoie pas au destinataire.
Voici le tcd:

J'ai utilisé ce code mais ça n'envoie toujours pas. Ça me crée juste un autre fichier excel avec la colonne "B3:B8"':
Merci.
Chris
J'essaie d'envoyer par mail une partie du tcd via vba mais tout ce que ça fait c'est que ça me crée un fichier excel avec la partie que j'ai sélectionné, mais ça n'envoie pas au destinataire.
Voici le tcd:

J'ai utilisé ce code mais ça n'envoie toujours pas. Ça me crée juste un autre fichier excel avec la colonne "B3:B8"':
Sub Mail_Range() Dim Source As Range Dim Dest As Workbook Dim wb As Workbook Dim TempFilePath As String Dim TempFileName As String Dim FileExtStr As String Dim FileFormatNum As Long Dim OutApp As Object Dim OutMail As Object Set Source = Nothing On Error Resume Next Set Source = Range("B3:B8").SpecialCells(xlCellTypeVisible) On Error GoTo 0 If Source Is Nothing Then MsgBox "The source is not a range or the sheet is protected, please correct and try again.", vbOKOnly Exit Sub End If With Application .ScreenUpdating = False .EnableEvents = False End With Set wb = ActiveWorkbook Set Dest = Workbooks.Add(xlWBATWorksheet) Source.Copy With Dest.Sheets(1) .Cells(1).PasteSpecial Paste:=8 .Cells(1).PasteSpecial Paste:=xlPasteValues .Cells(1).PasteSpecial Paste:=xlPasteFormats .Cells(1).Select Application.CutCopyMode = False End With TempFilePath = Environ$("temp") & "\" TempFileName = "Tableau stat" If Val(Application.Version) < 12 Then FileExtStr = ".xlsx": FileFormatNum = 51 End If Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) With Dest .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum On Error Resume Next With OutMail .to = "x" .CC = "x+1" .BCC = "x+2" .Subject = "Table statistique" .Body = "This is a test" .Attachments.Add Dest.FullName End With On Error GoTo 0 .Close savechanges:=False End With Kill TempFilePath & TempFileName & FileExtStr Set OutMail = Nothing Set OutApp = Nothing With Application .ScreenUpdating = True .EnableEvents = True End With End Sub
Merci.
Chris
A voir également:
- VBA - Envoyer un mail
- Gmail envoyer un mail - Guide
- Envoyer un mail en cci - Guide
- Windows live mail - Télécharger - Mail
- Publipostage mail - Accueil - Word
- Envoyer un mail avec accusé de reception gmail - Guide
Je l'ai remplacé et j'ai mit les adresses mails correctes mais ça ne marche toujours pas
mais ça ne marche toujours pas Qu'est-ce qui ne marche pas ?????