Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VFP60 outlook email attachment error 2

Status
Not open for further replies.

dakotafox

Programmer
Apr 14, 2000
53
US
msub=["]+enotes.programnam+["]
mnotes=["]+enotes.message+ImpMsgInfo+["]
mattach=[("c:\billmgmt\mstlist.xls",1,1,) "Just a test MSTLIST excel file attachment!"]
oSess =CREATEObject("MSMAPI.MAPISession")
if vartype(oSess) = "O"
oSess.DownloadMail = .f.
oSess.SignOn()
lnSessionID = oSess.SessionID
if lnSessionID > 0
oMsg = Createobject("MSMAPI.MAPIMessages")
*---we could possibly use vartype(oMsg) to control inhouse ="0" or outside ="1" ????????
if vartype(oMsg) = "O"
oMsg.SessionID = lnSessionID
oMsg.Compose()
oMsg.AddressResolveUI = .f.
*----------------------------------------------
oMsg.MsgSubject = &msub
oMsg.MsgNoteText = &mnotes
oMsg.Attachments.add(mattach)
Error message at this point
"Member attachments does not evaluate to an object"

??????

Thank you for your help.
 
mattach=["c:\billmgmt\mstlist.xls",1,1, "Just a test MSTLIST excel file attachment!"]

Then...

oMsg.Attachments.add(&mattach)

This will work ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Thanks for the suggested changes, but still get the same error message!!
 
I just created the following as Email.Prg
and run that from Command Prompt.. This worked very well.
*******************************************************
** Email.Prg
*******************************************************
myAttach = ["e:\email.prg",1,1, "Just a test file attachment!"]
o=createobject("outlook.application")
oitem=o.createitem(0)
oitem.subject="VFP6 rules"
oitem.to="ramani_g@yahoo.com"
oitem.body="This mail was sent from vfp client using Outlook98"
oitem.attachments.Add(&myAttach)
oitem.send
o=.null.
*******************************************************
** eof
*******************************************************
ramani :-9
(Subramanian.G)
FoxAcc
ramani_g@yahoo.com
LET KNOW IF THIS HELPED. ENOUGH EXPERTS ARE HERE TO HELP YOU OUT! BEST OF LUCK :)
 
Dakotafox,

The error you're getting is telling you that your oMsg object does not have an object called "Attachments". I tried creating one, and I get the same thing. Ramani's code is using Outlook instead, perhaps you should try that.
 
Okay gentlemen, I thank you very much. Outlook is working instead of mapi.
Now I am just trying to get it to work with multiple send to address from a memo file in the control table. Memlines and mline were working in in maping, but now the message I'm getting after it sends the first name is "Ole IDispatch exception code 4096 from Microsoft Outlook: The item has been moved or deleted..."
With step on the table is still open ?
Any suggestions.
 
Just found my solution so thought I would pass it on for reference.
If sending to multiple addresses the following will work
For i:1 to memlines(memo field)
oitem=o.createitem(0)
oitem.subject="VFP6 rules"
oitem.to="ramani_g@yahoo.com"
oitem.body="This mail was sent from vfp client using Outlook98"
oitem.attachments.Add(&myAttach)
oitem.send
next

this will allow multiple sends

Thanks for all your help
 
The MAPIMessage object doesnt support collections, as Outlook does. It uses index properties to coordinate multiple attachments/recipients. Hence, changing:

oMsg.Attachments.add(mattach)

to

oMsg.AttachmentIndex = 0
oMsg.AttachmentPathName = "c:\billmgmt\mstlist.xls"

should have resolved your issue.

See the following for more:

There are also threads here that discuss the MAPI controls. Do a keyword search. Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top