我在保存Outlook項目時遇到問題。 (嗯,我剛剛意識到我正在和Word一起工作 - 這有什麼關係嗎?我還可以在這裏發佈嗎?)無論如何,問題在於,Word正在創建消息併發送它很好(附件,主題和所有內容) ,但它不能正確地將文件保存在指定的位置。它保存爲1 KB而不打開。以下是代碼和錯誤圖片。非常感謝您的幫助!保存Outlook項目VBA問題
代碼:多大的幫助
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
謝謝!