我不是VBA的专家。我的代码是我在互联网上找到的好的复制粘贴工作表单代码。
差不多完成了,但是一件事一直困扰着我。
在邮件和签名中,我的tekst之间有2条白线。 我应该是1条白线。
但是如何:)
我希望有人能帮助我!
Sub mail_opdracht_mettler()
Dim objOutApp As Object, objOutMail As Object
Dim strBody As String, strSig As String
Dim subject As String
Set objOutApp = CreateObject("Outlook.Application")
Set objOutMail = objOutApp.CreateItem(0)
subject = Range("D8") & " - " & Range("B100") & " - " & Range("B1")
On Error Resume Next
With objOutMail
'SET THE EMAIL CONDITIONS
.To = "test@test.nl"
.CC = ""
.subject = subject
'IF SENT FROM ANOTHER EMAIL ACCOUNT (MUST ALREADY BE SETUP)
'.SentOnBehalfOfName = "test@test.nl"
'CHECK NAMES, ENSURES INTERNAL EMAIL ADDRESSES EXISTS IN ADDRESS BOOK
.Recipients.ResolveAll
'DO NOT REMOVE - THIS MUST BE VISIBLE FIRST TO GET THE DEFAULT SIGNATURE
.Display
'GET THE HTML CODE FROM THE SIGNATURE
strSig = .HTMLbody
'HTML TAGS CAN BE INCLUDED HERE
strBody = strBody = "<BODY style=font-size:10pt;font-family:Arial>Beste Angelique,<BR><BR></BODY>" & _
"<BODY style=font-size:10pt;font-family:Arial>Graag voor onderstaande winkel de volgende opdracht inplannen aub.<BR><BR></BODY>" & _
"<html>" & "<table style=font-size:10pt;font-family:Arial>" & "<tr>" & "<td width=150><b>" & Range("A1") & "</b></td>" & "<td width=300><b>" & Range("B1") & "</b></tr>" & _
"<tr>" & "<td width=150><b>" & Range("A2") & "</b></td>" & "<td width=300><b>" & Range("B2") & "</b></tr>" & _
"<tr>" & "<td width=150><b>" & Range("A3") & "</b></td>" & "<td width=300><b>" & Range("B3") & "</b></tr>" & _
"<tr>" & "<td width=150><b>" & Range("A4") & "</b></td>" & "<td width=300><b>" & Range("B4") & "</b></tr>" & _
"<tr>" & "<td width=150><b>" & Range("A5") & "</b></td>" & "<td width=300><b>" & Range("B5") & "</b></tr>" & _
"<tr>" & "<td width=150><b>" & Range("A6") & "</b></td>" & "<td width=300><b>" & Range("B6") & "</b></tr></table></html>" & _
"<hr noshade>" & _
"<BODY style=font-size:10pt;font-family:Arial><br><br>Type hier de opdracht<p></BODY>" & _
"<BODY style=font-size:10pt;font-family:Arial><br>Graag een bevestiging retour.<br></BODY>" & _
"<BODY style=font-size:10pt;font-family:Arial><br>Alvast bedankt.</BODY>"
'COMBINE THE EMAIL WITH THE SIGNATURE
.HTMLbody = strBody & strSig
'IF YOU DO NOT HAVE HTML IN THE BODY, USE THIS INSTEAD
'.Body = strBody & strSig
End With
resultaat = MsgBox("Is de mail verzonden?", vbYesNo)
If resultaat = vbYes Then
'datum wordt in cel gezet als de mail is verzonden
With Range("C27")
.Value = Date
.NumberFormat = "dd/mm/yyyy"
End With
Else
'datum van verzending later nog in de tabel zetten...
End If
On Error GoTo 0
Set objOutMail = Nothing
Set objOutApp = Nothing
End Sub
我添加了HTML。