VBA Code para enviar mail con varias lineas en el cuerpo
Publicado por Fernando (2 intervenciones) el 31/05/2021 19:00:32
Estimados tengo el siguiente codigo en una macro de Excel, pero necesitaba poder incorporar mas lineas al Body del mail, ya que solo me muestra en este caso Q19. El contenido del body que quiero mostrar seria Q19:T31
El codigo es:
Muchas Gracias
El codigo es:
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
Private Sub CommandButton1_Click()
Dim objOutlook As Object
Dim objMail As Object
Dim OApp As Object, OMail As Object, signature As String
Dim rngTo As Range
Dim rngSub As Range
Dim rngMessage As Range
Dim rngAttachment As Range
Set objOutlook = CreateObject("Outlook.Application")
Set OApp = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
Set OMail = OApp.CreateItem(0)
With OMail
.Display
End With
signature = OMail.HTMLBody
With ActiveSheet
Set rngTo = .Range("Q13")
Set rngSub = .Range("Q18")
Set rngMessage = .Range("Q19")
End With
With OMail
.To = rngTo.Value
.Subject = rngSub.Value
.HTMLBody = rngMessage + signature
.Display
End With
Set objOutlook = Nothing
Set objMail = Nothing
Set rngTo = Nothing
Set rngSub = Nothing
Set rngMessage = Nothing
Set rngAttachment = Nothing
End Sub
Muchas Gracias
Valora esta pregunta


0