>我创建了一个VB6应用程序,其中包含一个基本上可以发送和接收电子邮件的服务,该服务使用Windows 2003 serverR2中配置的服务帐户和mapi配置文件。
当交换服务器和域帐户位于同一网络中时,这是有效的。 一旦交换服务器被更改,服务将无法发送或接收电子邮件,给出错误
Microsoft 交换不可用。 存在网络问题或 Exchange 计算机已关闭以进行维护。[Microsoft Exchange 信息存储 - [MAPI_E_FAILONEPROVIDER(8004011D(]],协作数据对象。
我已经搜索了这个错误,但我无法收集所有信息,因为解释是针对同一网络的。任何人都可以请您建议我能做些什么来解决这个问题?谢谢
MAPI也已由Microsift停止使用,正如@bob77所建议的那样。我建议使用SMTP或EWS。
话虽如此,如果你仍然想去它。请在下面找到工作代码:
Set objMAPI = New MAPI.Session
objMAPI.Logon ShowDialog:=False, NewSession:=False, ProfileInfo:=gobjINI.gstrExchangeServer & vbLf & gobjINI.gstrProfile
'Add a new mesage to the OUtbo Messages Collection
Set objMSG = objMAPI.Outbox.Messages.Add
Set fsoMy_File_Sys_Obj = New FileSystemObject
'Add the recipient list specified in INI File
'Check if this is a multiple Recipient List (names or groups seperated by semicolons!)
If InStr(1, Recipients, ";") Then
objMSG.Recipients.AddMultiple Recipients, CdoTo
objMSG.Recipients.Resolve
Else
'This section is for handling of single recipient name
'Be aware that this may be an email group list name !
Set objRecipients = objMSG.Recipients.Add(Recipients)
objRecipients.Resolve
End If
'Add an attachment if needed
If Attachment_Name <> "" Then
bolAttach_File_Exists = fsoMy_File_Sys_Obj.FileExists(Attachment_Path)
If bolAttach_File_Exists = True Then
'Open the attachment file and add it to the message text
Set tsAttachment = fsoMy_File_Sys_Obj.OpenTextFile(Attachment_Path)
Do While Not tsAttachment.AtEndOfStream
strAttachment_Read = tsAttachment.ReadLine
Message = Message & strAttachment_Read & vbCrLf
Loop
tsAttachment.Close
Else
gobjMAPI.MailSend gobjINI.gstrMailRecipients, "Email Send - Attachment Addition", "Attempted To Attach A File That Does Not Exist", "", ""
End If
End If
'Add Subject Line, Message Content and Send Message
objMSG.Subject = Subject
objMSG.Text = Message
objMSG.Importance = mapiHigh
'The Update method adds all our assignments to collecttion
objMSG.Update
'Now let's actually send the message
objMSG.Send
'End MAPI Session
objMAPI.Logoff
Set objMAPI = Nothing