Bonjour,

Je dois envoyer un email soit en allemand, soit en français suivant la valeur d'une cellule (FR ou DE).
j'ai voulu utiliser un If... then... mais il ne me reconnaît pas le bloc.

Quelqu'un a une idée svp?

Voici mon code :


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
Sub Envoyer()
 
Dim Chemin As Variant
Dim myApp As Object, myitem As Object, signature As String
Dim Langue As String
 
Dim sFind
Dim nSearch2 As String
nSearch2 = Range("e3").Value
Langue = "DE"
Chemin = Worksheets("EnvoiDocs").Range("sCS").Offset(0, 3).Value
 
Set sFind = Sheets("EnvoiDocs").Columns(8).Find(nSearch2, LookIn:=xlValues, MatchCase:=False)
    If Not sFind Is Nothing Then
       Range(sFind.Address).Name = "sCS"
       Range("sCS").Select
    End If
 
 
If Range("sCS").Offset(0, 3).Value = Langue Then GoTo mailDE
End If
 
Set myApp = CreateObject("Outlook.Application")
Set myitem = myApp.CreateItem(olMailItem)
With myitem
    .Display
    End With
        signature = myitem.body
 
With myitem
myitem.Subject = "Envoi d'informations " & Worksheets("EnvoiDocs").Range("sCS").Offset(0, 1).Value
myitem.body = "Bonjour," & _
vbNewLine & signature
 
 
myitem.Attachments.Add Chemin
myitem.to = "xxxx.xxxx@xxxx.com"
End With
 
End Sub