VB6应用程序连接到mapi

时间:2017-03-17 10:53:03

标签: windows vb6

我创建了一个VB6应用程序,其中包含基本上发送和接收电子邮件的服务,该服务使用Windows 2003 serverR2中配置的服务帐户和mapi配置文件。

当Exchange服务器和域帐户都在同一网络中时,这是有效的。一旦交换服务器被更改,服务就无法发送或接收发送错误的电子邮件

  

Microsoft Exchange不可用。存在网络问题或Exchange计算机因维护而关闭。 [Microsoft Exchange信息存储 - [MAPI_E_FAILONEPROVIDER(8004011D)]],协作数据对象。

我已经搜索了这个错误,但由于对同一网络的解释,我无法收集所有错误。 任何人都可以请你建议我能做些什么来解决这个问题? 谢谢,

1 个答案:

答案 0 :(得分:0)

正如@ bob77所建议的那样,MAPI已停止使用MAPI。 我建议使用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