嗨,大家好,我在发送多个电子邮件时遇到了相同的问题,这些电子邮件是我从单词文件模板复制的相同单词文件模板。 这是我的代码
Sub emailsendout()
On Error GoTo Endnow
Application.ScreenUpdating = False
Dim WordDoc As Object
Dim WordFile As String
WordFile = Cells(1, 1).Value '<===word file path store at cell(1,1)
Set WordDoc = GetObject(WordFile)
Dim OutApp As Object, OutMail As Object, OutWordEditor As Object
Set OutApp = CreateObject("Outlook.Application")
On Error GoTo cleanup
Dim cell As Range
For Each cell In Columns("C").Cells.SpecialCells(xlCellTypeConstants)
If LCase(Cells(cell.Row, "B").Value) = "y" Then '<==create email if yes
Set OutMail = OutApp.CreateItem(0)
Set OutWordEditor = OutMail.GetInspector.WordEditor
On Error Resume Next
With OutMail
.To = cell.Value
.cc = cell.Offset(, 2)
.Subject = Cells(cell.Row, "G").Value
.Body = Cells(cell.Row, "F").Value '<===e.g.: Dear Mr.A
Set editor = .GetInspector.WordEditor
editor.Content.Paste
Set WordDoc = GetObject(WordFile)
WordDoc.Content.Copy
OutWordEditor.Content.Paste
OutWordEditor.Range(0).InsertBefore (Cells(cell.Row, "F").Value & vbCrLf & vbCrLf) '<==copy and paste word content after Dear Mr.A
WordDoc.Close
.Attachments.Add (Cells(cell.Row, "H").Text)
.Attachments.Add (Cells(cell.Row, "I").Text)
.Save
'.Send '<===problem is here
End With
On Error GoTo 0
Set OutMail = Nothing
End If
Next cell
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
Endnow:
当我将电子邮件创建为草稿时,单词模板的正文副本是完美的。但是,如果我将命令从.Save更改为.Send并直接发送多封电子邮件,而不保存草稿。电子邮件正文的全部内容都消失了。...
有人可以告诉我这个问题吗?