我试图从Outlook使用与我的默认设置不同的Outlook地址发送传真。以下是我的代码。使用不同的Outlook电子邮件地址从Access发送电子邮件
谢谢。
私人小组FaxDoctor()“传真的医生信 对错误转到Error_Handler 昏暗FSO
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
Exit_Procedure: 上的错误继续下一步 退出小组 Error_Handler: MSGBOX(”无字母找到“& vbCrLf &”如果您确定这封信是以正确的文件名保存的,请关闭Outlook并再试一次。“)”这经常崩溃,因为没有找到该信件或因为outlook崩溃。在这种情况下,应关闭每个Outlook进程并重新启动Outlook。 Exit Sub End Sub