我正在从我的 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
我已将 SMRecipients 设置为单个电子邮件地址,这很好,但是当我添加更多用分号或空格分隔的地址时,它只会发送到原始地址。
我的系统在 XP 下运行。
另一点是,它用于在 Outlook 通讯簿中查找地址,并且在它们不够具体的地方,它会显示匹配的地址以选择正确的地址。它不再这样做了。