清除html保留段落,保留原始段落间距与HTMLbody

Dim OutLookApp As Object

Dim OutLookMailItem As Object

Dim lastrow As Long

Dim iCounter As Long

Dim MailDest As String

Dim subj As String

Dim bod As String

Dim ws As Worksheet

Dim signature As String

lastrow = ThisWorkbook.Worksheets("Prospects").Cells(Rows.Count, "D").End(xlUp).Row 'change worksheet

For iCounter = 2 To lastrow

Set OutLookApp = CreateObject("Outlook.application")

Set OutLookMailItem = OutLookApp.CreateItem(0)

signature = Environ("appdata") & "\Microsoft\Signatures\"

If Dir(signature, vbDirectory) <> vbNullString Then

signature = signature & Dir$(signature & "*.htm")

Else:

signature = ""

End If

signature = CreateObject("Scripting.FileSystemObject").GetFile(signature).OpenAsTextStream(1, -2).ReadAll

With OutLookMailItem

subj = ""

MailDest = ""

bod = ""

If Cells(iCounter, 13) = "*" Then

subj = Cells(iCounter, 14).Value

MailDest = Cells(iCounter, 7).Value

bod = Cells(iCounter, 16).Value

.BCC = MailDest

.Subject = subj

.HTMLBody = bod & signature

.Send

End If

End With

Next iCounter

End Sub

上述代码自动发送电子邮件到电子邮件地址的列和它得到从Excel中的列中的身体段为好。

我希望我的邮件在Outlook中包含我的默认签名,所以我将我的代码更改为HTMLbody。

送出不会保留原来的段落间距的电子邮件:

line 1

line 2

line 3

它看起来像现在这样:line1 line2 line3。

2015-11-25

Daruki

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值