Bonjour
j'ai un probléme la macro génere un fichier "j1.xls" dans mon dossier en plus de mon fichier existant
comment peut t'on éviter d'avoir un deuxieme fichier
Merci pour votre aide
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 Sub CDO_Mail_Small_Text_2() Dim iMsg As Object Dim iConf As Object Dim strbody As String Dim Flds As Variant Dim Fichier As String Dim SourceWb As Workbook Set SourceWb = ActiveWorkbook Fichier = ThisWorkbook.Path & Application.PathSeparator & "j1.xls" SourceWb.SaveCopyAs Fichier Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") iConf.Load -1 ' CDO Source Defaults Set Flds = iConf.Fields With Flds .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "..........." .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "........" .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com" .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 .Update End With strbody = "Bonjour, Voici le planning . Merci!" With iMsg Set .Configuration = iConf .to = ".................." .CC = "..........." .BCC = "" ' Note: The reply address is not working if you use this Gmail example ' It will use your Gmail address automatic. But you can add this line ' to change the reply address .ReplyTo = "Reply@something.nl" .From = """..........."" <................>" .Subject = "planning" .TextBody = strbody .AddAttachment Fichier .Send End With End Sub
Partager