labonisimo
New Member
- Joined
- Mar 9, 2022
- Messages
- 3
- Office Version
- 2016
- Platform
- Windows
Hi there,
I am using an excel template to send emails from excel. It all works fine but does not add my standard signature to it. I tweaked it a little, however doesnt do what it should do. It now adds my signature but not correctly (doesnt show images and shows hyperlinks.
Maybe you can help me fix it.
I am using an excel template to send emails from excel. It all works fine but does not add my standard signature to it. I tweaked it a little, however doesnt do what it should do. It now adds my signature but not correctly (doesnt show images and shows hyperlinks.
Maybe you can help me fix it.
VBA Code:
Option Explicit
Sub Send_Mails()
Dim emailMail As Object, signature As String
Dim sh As Worksheet
Set sh = ThisWorkbook.Sheets("Send_Mails")
Dim i As Integer
Dim OA As Object
Dim msg As Object
Set OA = CreateObject("outlook.application")
Set emailMail = OA.CreateItem(0)
Dim last_row As Integer
last_row = Application.CountA(sh.Range("A:A"))
For i = 2 To last_row
With emailMail
.Display
End With
signature = emailMail.Body
Set msg = OA.CreateItem(0)
msg.To = sh.Range("A" & i).Value
msg.cc = sh.Range("B" & i).Value
msg.Subject = sh.Range("C" & i).Value
msg.Body = sh.Range("D" & i).Value & signature
If sh.Range("E" & i).Value <> "" Then
msg.attachments.Add sh.Range("E" & i).Value
End If
msg.send
sh.Range("F" & i).Value = "Sent"
Next i
MsgBox "An alle Mitarbeiter verschickt"
End Sub