Problem with sending mail to more than one recipient

  • Thread starter Thread starter sushe
  • Start date Start date
S

sushe

I am trying to access MS Outlook from an application developed in VB by
the code:

Dim olApp, myNameSpace, objNewMail As Object

Set olApp = CreateObject("Outlook.Application")
Set myNameSpace = olApp.GetNamespace("MAPI")

Const olMailItem = 0
Set objNewMail = olApp.CreateItem(olMailItem)

With objNewMail

If txtTill.text <> "" Then
..Recipients.Add txtTill.text
End If

..Importance = 2 'olImportanceHigh
..Subject = txtRubrik.text
..Body = szEpostInnehall
..Send
'.Display
End With

The problem occurrs when the string txtTill.txt contains more than one
recipient ex;

(e-mail address removed); (e-mail address removed)

If I use

..Send

Outlook only sends mail to the second mailadress ([email protected]) and
gives a message that it cannot resolve the first address. I get the
email back and a message that says that it is an illegal end of a route
address, missing end of address.

If I use

..Display

and gives outlook for about 10 seconds it seems like it interprets (and
compares) the addresses and can send an email to both of them. But if I
just click on the send button in the displayed email immidiately I get
the same problem as in the first case when I use

..Send

Outlook cannot resolve the first address.

Is there any way to get round this problem? To me it seems like the
problem is that Outlook needs time to interpret the line of recipients
and cannot resolve them if I dont use to display the line of recipients
and give it ten seconds to do it. I need to use the

..Send

function and send email to more recipients than one.

Greatful for help

/Sushe
 
Perhaps the problem is with one specific e-mail address,
not your code. You can force Outlook to resolve all e-mail
addresses, telling you the ones it can't, with code like
this:

If Not .Recipients.ResolveAll Then
For Each myRecipient In myRecipients
If Not myRecipient.Resolved Then
MsgBox myRecipient.Name
End If
Next
End If


Good luck!

-Andrew Cushen
=========================
 
Back
Top