Visual Basic para Aplicaciones - Alguien me puede ayuda?

Life is soft - evento anual de software empresarial
   
Vista:
Imágen de perfil de miguel

Alguien me puede ayuda?

Publicado por miguel (14 intervenciones) el 19/12/2017 14:39:18
Alguien puede ayudarme a entender como envia los emails este cogido es de un excel que hace una encuesta y despues la envia por pdf

Entiendo que en .To envia el email por medio de la variable destinee pero no se donde toma los emails?

me orientan?


Este es el codigo que va en el boton de enviar
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
57
58
Sub Survey_Complete()
'
'
Dim namefile As String
Dim TempFilePath As String
Dim service As String
Dim cellule As Range
'
service = ""
For Each cellule In Range("EPMT_Group")
    If cellule.Value = "X" Then service = cellule.Offset(0, 1).Value
Next
 
On Error Resume Next
 
    Range("Survey").Select
    namefile = "Customer_Survey - " & service & " - " & Date$ & ".pdf"
    Selection.ExportAsFixedFormat Type:=xlTypePDF, _
        Filename:=Environ$("temp") & "\" & namefile, _
        Quality:=xlQualityStandard, _
        OpenAfterPublish:=False
    'plage.
 
 
'Create a new Microsoft Outlook session
Set appOutlook = CreateObject("outlook.application")
 
'create a new message
Set Message = appOutlook.CreateItem(olMailItem)
 
TempFilePath = Environ$("temp") & "\"
If Application.WorksheetFunction.CountA(Range("Send_to")) = 0 Then
    MsgBox ("Please select customer survey destinee")
    Exit Sub
End If
For Each cellule In Range("Send_to")
    destinee = destinee & ";" & cellule.Value2
Next
With Message
    .Subject = "Customer Survey - " & service & " - " & Date$
    .HTMLBody = "<span LANG=EN>" _
        & "<p class=style2><span LANG=EN><font FACE=Calibri SIZE=3>" _
        & "Hello,<br ><br >Please find in attachment the customer survey for your services. <BR>" _
        & "<br>Best Regards,<br> </font></span>"
 
    .Attachments.Add TempFilePath & namefile, olByValue, 1
 
    .To = destinee
    Validation = MsgBox("Are you sure you want to send this Customer Survey?", vbYesNo)
    If Validation = 7 Then
        MsgBox ("Please validate the created email")
        .display
    Else
        .Send
    End If
    MsgBox ("Thanks a lot for taking the time to let us know how to improve.")
End With
End Sub


este codigo marca con X a quien se le va a enviar el email:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count = 1 Then
    If Not (Application.Intersect(Range("EPMT_Group"), Target) Is Nothing) Then Range("EPMT_Group").ClearContents: Target.Value = "X"
    If Not (Application.Intersect(Range("Quality1"), Target) Is Nothing) Then Range("Quality1").ClearContents: Target.Value = "X"
    If Not (Application.Intersect(Range("Quality2"), Target) Is Nothing) Then Range("Quality2").ClearContents: Target.Value = "X"
    If Not (Application.Intersect(Range("Productivity1"), Target) Is Nothing) Then Range("Productivity1").ClearContents: Target.Value = "X"
    If Not (Application.Intersect(Range("Productivity2"), Target) Is Nothing) Then Range("Productivity2").ClearContents: Target.Value = "X"
    If Not (Application.Intersect(Range("HumDev1"), Target) Is Nothing) Then Range("HumDev1").ClearContents: Target.Value = "X"
    If Not (Application.Intersect(Range("Overall1"), Target) Is Nothing) Then Range("Overall1").ClearContents: Target.Value = "X"
    If Not (Application.Intersect(Range("Overall2"), Target) Is Nothing) Then Range("Overall2").ClearContents: Target.Value = "X"
    If Not (Application.Intersect(Range("Overall3"), Target) Is Nothing) Then Range("Overall3").ClearContents: Target.Value = "X"
    If Not (Application.Intersect(Range("Cust1"), Target) Is Nothing) Then Range("Cust1").ClearContents: Target.Value = "X"
    If Not (Application.Intersect(Range("Cust2"), Target) Is Nothing) Then Range("Cust2").ClearContents: Target.Value = "X"
    If Not (Application.Intersect(Range("Cust3"), Target) Is Nothing) Then Range("Cust3").ClearContents: Target.Value = "X"
    If Not (Application.Intersect(Range("destinees"), Target) Is Nothing) Then
        If Target.Value = "X" Then Target.Value = "": Exit Sub
        If Target.Value = "" Then Target.Value = "X": Exit Sub
    End If
End If
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder