我在保存outlook项目时遇到问题。 (嗯,我刚才意识到我和Word女士一起工作 - 这有关系吗?我还能在这里发帖吗?)无论如何,问题是,Word正在创建消息并发送它就好了(附件,主题和所有内容) ,但它没有正确地将文件保存在指定位置。它保存为1 KB而不是打开。下面是代码和错误的图像。非常感谢你的帮助!
代码:
Private Sub CommandButton1_Click()
Dim myString As String
Dim myString2 As String
Set myOlApp = CreateObject("Outlook.Application")
Set myItem = myOlApp.CreateItem(olMailItem)
' Doing some texts replacements here.
myString = Label9
myString = Replace(myString, "[Name of Person]", TextBoxNoP.Value)
myString = Replace(myString, "[Name of Establishment]", TextBoxNoE.Value)
myString = Replace(myString, "[Date Received]", TextBoxDR.Value)
myString2 = Label10
myString2 = Replace(myString2, "[Name of Establishment]", TextBoxNoE.Value)
myString2 = Replace(myString2, "[Date Received]", TextBoxDR.Value)
' Done with texts replacements here. Setting up, saving and sending messages.
Set myAttachments = myItem.Attachments
myItem.To = TextBoxTo.Value
myItem.CC = TextBoxCC.Value
myItem.Subject = myString2
myAttachments.Add "\\di-afs.doi-ad.state.nv.us\LifeHealth\Charitable Gift Annuities\Charitable Gift Annuities 2016\Pending Charitable Gift Annunites\" & TextBoxAtt.Value & ".pdf"
myItem.Body = myString
myItem.SaveAs "\\di-afs.doi-ad.state.nv.us\LifeHealth\Charitable Gift Annuities\Charitable Gift Annuities 2016\E-mails sent by Nanci\" & myString2 & ".msg", olMsg
myItem.Send
Unload Me
End Sub
非常感谢你的帮助!!
答案 0 :(得分:0)
在调用SaveAs之前尝试调用myItem.Save。
答案 1 :(得分:0)
我明白了。
我需要从SaveAs行的末尾删除“,olMsg”部分。不管怎样,谢谢!