Vb6 使用多个电子邮件地址从VB运行Outlook

Vb6 使用多个电子邮件地址从VB运行Outlook,vb6,outlook,windows-xp,Vb6,Outlook,Windows Xp,我正在从我的VB6系统发送电子邮件,我在向不同的电子邮件地址发送单个电子邮件时遇到问题。代码如下: On Error Resume Next Err.Clear Set oOutLookObject = CreateObject("Outlook.Application") If Err <> 0 Then MsgBox "Email error. Err = " & Err & " Description = " & Err.Description

我正在从我的VB6系统发送电子邮件,我在向不同的电子邮件地址发送单个电子邮件时遇到问题。代码如下:

On Error Resume Next
Err.Clear
Set oOutLookObject = CreateObject("Outlook.Application")
If Err <> 0 Then
    MsgBox "Email error. Err = " & Err & " Description = " & Err.Description
    EmailValid = "N"
    Exit Function
End If
Set oEmailItem = oOutLookObject.CreateItem(0)
If Err <> 0 Then
    MsgBox "Email error. Err = " & Err & " Description = " & Err.Description
    EmailValid = "N"
    Exit Function
End If
With oEmailItem
    .Recipients.Add (SMRecipients)
    .Subject = SMSubject
    .Importance = IMPORTANCENORMAL
    .Body = SMBody
    For i = 1 To 10
        If RTrim(SMAttach(i)) <> "" Then
            .attachments.Add SMAttach(1)    'i)
        Else
            Exit For
        End If
    Next i
    .send
End With
If Err <> 0 Then
    MsgBox "Email error. Err = " & Err & " Description = " & Err.Description
    EmailValid = "N"
    Exit Function
End If
'''   .Attachments.Add ("c:\temp\test2.txt")
Set oOutLookObject = Nothing
出错时继续下一步
呃,明白了
设置oOutLookObject=CreateObject(“Outlook.Application”)
如果错误为0,则
MsgBox“Email error.Err=“&Err&”Description=“&Err.Description
EmailValid=“N”
退出功能
如果结束
设置oEmailItem=oOutLookObject.CreateItem(0)
如果错误为0,则
MsgBox“Email error.Err=“&Err&”Description=“&Err.Description
EmailValid=“N”
退出功能
如果结束
带oEmailItem
.Recipients.Add(SMRecipients)
.Subject=SMSubject
.重要性=重要性正常
.Body=SMBody
对于i=1到10
如果RTrim(SMAttach(i))”“那么
.附件.添加附件(1)'i)
其他的
退出
如果结束
接下来我
.发送
以
如果错误为0,则
MsgBox“Email error.Err=“&Err&”Description=“&Err.Description
EmailValid=“N”
退出功能
如果结束
''.Attachments.Add(“c:\temp\test2.txt”)
设置oOutLookObject=Nothing
我已将SMRecipients设置为单个电子邮件地址,这很好,但当我添加更多以分号或空格分隔的地址时,它只会发送到原始地址

我的系统在XP下运行


另一点是,它用于在Outlook通讯簿中查找地址,如果地址不够具体,它将显示匹配的地址,以便选择正确的地址。它不再这样做。

使用
.Recipients.Add()
时,您需要自己拆分收件人,将每个收件人传递给
.Add()


使用
.Recipients.Add()
时,您需要自己拆分收件人,将每个收件人传递给
.Add()


这个问题似乎更适合SO。这个问题与本网站无关,请参阅;我已将其标记为迁移到堆栈溢出。@Mac:只需将以分号分隔的电子邮件地址传递到
.to
.Cc
.Bcc
属性
oEmailItem
。类似于
“用户;另一个用户”
的问题也可以。这个问题似乎更适合这样。这个问题与本网站无关,请参阅;我已将其标记为迁移到堆栈溢出。@Mac:只需将以分号分隔的电子邮件地址传递到
.to
.Cc
.Bcc
属性
oEmailItem
。类似于
“用户;另一个用户”
的东西也可以。
Dim RecipientList() As String
Dim RecipientString As String
Recipients = Split(SMRecipients, ";")
For Each RecipientString in Recipients
  .Recipients.Add RecipientString
Next