Outlook 2003 Change

  • Thread starter Thread starter Robert Braunlich
  • Start date Start date
R

Robert Braunlich

I have a custom app written in VFP that I use to send e-
mails. It worked well using Outlook 2000 and 2002. I
use the MAPI namespace.

In Outlook 2003 it fails on the send with the message

OLE IDispatch exception code 4096 from Microsoft Office
Outlook: Outlook does not recognize one or more names

What changed?
 
The error message means what it says: One or more recipient names could not
be resolved to addresses. Show a sufficient code snippet to demonstrate how
you're creating and
sending the message.
 
Thanks for your reply. Here is some code. It fails on
the second line from the bottom.

lo_App = CREATEOBJECT("Outlook.Application")
lo_NameSpace = lo_App.GetNameSpace("MAPI")
lo_Msg = lo_NameSpace.GetDefaultFolder(6)

lo_New = lo_Msg.Items.ADD()

if ! empty(alltrim(thisform.txtsendto.value))
lc_sendto = alltrim(thisform.txtsendto.value)
lo_New.Recipients.ADD(lc_sendto)
endif

FOR i = 1 TO THISFORM.lbxaddressbook.LISTCOUNT
IF THISFORM.lbxaddressbook.SELECTED(i)
lc_sendto = ALLTRIM(THISFORM.lbxaddressbook.LIST(i))
lo_New.Recipients.ADD(lc_sendto)
ENDIF
ENDFOR

lo_New.Subject = ALLTRIM(THISFORM.txtsubject.VALUE)
lo_New.Body = ALLTRIM(THISFORM.edtmsgtext.VALUE)
lo_New.Attachments.ADD(ALLTRIM
(THISFORM.savefile1),1,1,ALLTRIM(THISFORM.savefile1))
IF ! EMPTY(ALLTRIM(THISFORM.savefpt1))
lo_New.Attachments.ADD(ALLTRIM
(THISFORM.savefpt1),1,1,ALLTRIM(THISFORM.savefpt1))
ENDIF
IF ! EMPTY(ALLTRIM(THISFORM.savefile2))
lo_New.Attachments.ADD(ALLTRIM
(THISFORM.savefile2),1,1,ALLTRIM(THISFORM.savefile2))
ENDIF
IF ! EMPTY(ALLTRIM(THISFORM.savefpt2))
lo_New.Attachments.ADD(ALLTRIM
(THISFORM.savefpt2),1,1,ALLTRIM(THISFORM.savefpt2))
ENDIF

*-- HERE IS WHERE THE CODE FAILS --*
lo_New.SEND()

RELEASE lo_App
 
lc_sendto would be the name, not the email address from the address book. If
you have two people with the same name in the default address book, it won't
resolve. A better approach is to get the AddressEntry object for each
selected item in the address book and use its Address property. That's
guaranteed to resolve without problems.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top