Hi All,
I get the error "Run-time error -2147467259 (80004005) Outlook does not recognize one or more names" when I try to run myitem.send - myitem is defined as an object. Any help would be appreciated. Thanks.
Situation:
Basically I am getting the email address from my membership table and chopping it up into pieces of 25 names (because that is as much as my isp can handle). Once I have got 25 names, I will then create a email in outlook using myitem.send. This loops until I have exhausted all the names in my membership table. Mail is generated in Outlook but it breaks down before all the emails has been created. Is this a limit thing???
Code enclosed:
Set appOutl = CreateObject("Outlook.Application")
Set MyNameSpace = appOutl.getNameSpace("MAPI")
sMailList = fEmailList()
bContinue = True
nMailCreated = 0
nNumTotAddress = 0
Do While bContinue = True
Set myitem = appOutl.CreateItem(0)
myitem.To = gbEmailAddress
nNumAddress = 0
nLength = Len(sMailList)
'retrieve 25 email address for bcc because that is limit for icare
Do While nNumAddress <= 24
'nPos = 0 (";" cannot be found)
nPos = InStr(1, sMailList, ";")
If nPos > 0 Then
nNumAddress = nNumAddress + 1
nNumTotAddress = nNumTotAddress + 1
If nNumAddress = 1 Then
myitem.bcc = myitem.bcc & Left(sMailList, nPos)
Else
myitem.bcc = myitem.bcc & ";" & Left(sMailList, nPos)
End If
sMailList = Mid(sMailList, nPos + 1, nLength - nPos + 1)
nLength = Len(sMailList)
End If
'Last ";" found
If nLength = 0 Then
nNumTotAddress = nNumTotAddress + 1
bContinue = False
Exit Do
End If
Loop
'remove ";" from end of string
If nLength <> 0 Then
myitem.bcc = Mid(myitem.bcc, 1, nLength - 1)
End If
If Not IsNull(Me.Text7) Then
myitem.Subject = Me.Text7
End If
If Not IsNull(Me.Text9) Then
myitem.Body = Me.Text9
End If
If Not IsNull(Me.Text2) Then
myitem.Attachments.Add "" & Me.Text2 & ""
End If
myitem.Send
nMailCreated = nMailCreated + 1
LoopSituation:
I get the error "Run-time error -2147467259 (80004005) Outlook does not recognize one or more names" when I try to run myitem.send - myitem is defined as an object. Any help would be appreciated. Thanks.
Situation:
Basically I am getting the email address from my membership table and chopping it up into pieces of 25 names (because that is as much as my isp can handle). Once I have got 25 names, I will then create a email in outlook using myitem.send. This loops until I have exhausted all the names in my membership table. Mail is generated in Outlook but it breaks down before all the emails has been created. Is this a limit thing???
Code enclosed:
Set appOutl = CreateObject("Outlook.Application")
Set MyNameSpace = appOutl.getNameSpace("MAPI")
sMailList = fEmailList()
bContinue = True
nMailCreated = 0
nNumTotAddress = 0
Do While bContinue = True
Set myitem = appOutl.CreateItem(0)
myitem.To = gbEmailAddress
nNumAddress = 0
nLength = Len(sMailList)
'retrieve 25 email address for bcc because that is limit for icare
Do While nNumAddress <= 24
'nPos = 0 (";" cannot be found)
nPos = InStr(1, sMailList, ";")
If nPos > 0 Then
nNumAddress = nNumAddress + 1
nNumTotAddress = nNumTotAddress + 1
If nNumAddress = 1 Then
myitem.bcc = myitem.bcc & Left(sMailList, nPos)
Else
myitem.bcc = myitem.bcc & ";" & Left(sMailList, nPos)
End If
sMailList = Mid(sMailList, nPos + 1, nLength - nPos + 1)
nLength = Len(sMailList)
End If
'Last ";" found
If nLength = 0 Then
nNumTotAddress = nNumTotAddress + 1
bContinue = False
Exit Do
End If
Loop
'remove ";" from end of string
If nLength <> 0 Then
myitem.bcc = Mid(myitem.bcc, 1, nLength - 1)
End If
If Not IsNull(Me.Text7) Then
myitem.Subject = Me.Text7
End If
If Not IsNull(Me.Text9) Then
myitem.Body = Me.Text9
End If
If Not IsNull(Me.Text2) Then
myitem.Attachments.Add "" & Me.Text2 & ""
End If
myitem.Send
nMailCreated = nMailCreated + 1
LoopSituation: