【发布时间】:2016-05-22 08:57:35
【问题描述】:
我正在尝试使用与我的默认地址不同的 Outlook 地址从 Outlook 发送传真。下面是我的代码。
谢谢。
Private Sub FaxDoctor() ' 用信件传真医生 出错时转到 Error_Handler 暗淡无光
Dim olApp As Object
' Dim olApp As Outlook.Application
Dim olNS As Outlook.NameSpace
Dim olfolder As Outlook.MAPIFolder
Dim olMailItem As Outlook.MailItem
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists("\\pna434h0360\PharmServ\Output\" & Me!ID & ".pdf") Then ' If the filename is found
Set olApp = CreateObject("Outlook.Application")
Set olNS = olApp.GetNamespace("MAPI")
Set olfolder = olNS.GetDefaultFolder(olFolderInbox)
Set olMailItem = olfolder.Items.Add("IPM.Note")
olMailItem.display
With olMailItem
.Subject = " "
.To = "[fax:" & "Dr. " & Me.[Prescriber First Name] & " " & Me.[Prescriber Last Name] & "@" & 1 & Me!Fax & "]" ' Must be formatted exactly to be sent as a fax
'.Body = "This is the body text for the fax cover page" ' Inserts the body text
.Attachments.Add "\\pna434h0360\PharmServ\Output\" & Me!ID & ".pdf" ' attaches the letter to the e-mail/fax
'.SendUsingAccount = olNS.Accounts.Item(2) 'Try this to change email accounts
End With
Set olMailItem = Nothing
Set olfolder = Nothing
Set olNS = Nothing
Set olApp = Nothing
Else
GoTo Error_Handler
End If
退出程序: 出错时继续下一步 退出子 错误处理程序: MsgBox ("No Letter found" & vbCrLf & "如果您确定该字母以正确的文件名保存,则关闭 Outlook 并重试。") ' 这通常会崩溃,因为找不到该字母或 Outlook 已崩溃。在这种情况下,应关闭每个 Outlook 进程并重新启动 Outlook。 退出子 结束子
【问题讨论】:
标签: ms-access