Troy,
I have added at least one recipient, maybe that is it
fyi, the curdir gets reset when you execute the signon()
see changes below
>I get an 'unspecified ole error' when running the following code in the send method of the message object.
>
>This should be a very simple operation: simply compose a message, optionally add attachemnts, and optionally compose or directly send the email thru the mapi API.
>
>Is there anyone out there that understands the MAPI 'stuff' well enough to point out what is wrong with the following code
>
>Thanks in advance!
>
>
>DEFINE CLASS eMail AS custom
> *Send email's
> HIDDEN logsession, oleMmess, oleMsess, cCurDir
> lAutoSend = .F.
> logsession = .F.
> cTo = ''
> cCC = ''
> cBCC = ''
> cErrMsg = ''
> cAttachments = ''
> cSubject = ''
> cBody = ''
> oleMmess = null
> oleMsess = null
>
> HIDDEN PROCEDURE Init
> this.logsession = .F.
> this.cCurDir=FULLPATH(CURDIR())
> IF !FILE(GETENV("WINDIR")+"\SYSTEM32\MAPI32.DLL") AND !FILE(GETENV("WINDIR")+"\SYSTEM\MAPI32.DLL")
> this.cErrMsg='It does not appear that you have MAPI installed. Mail could not be run.'
> RETURN .F.
> ENDIF
> this.olemmess=CREATEOBJECT('MSMAPI.MAPIMessages')
> this.oleMsess=CREATEOBJECT('MSMAPI.MAPISession')
> ENDPROC
>
> HIDDEN PROCEDURE Destroy
> * For some reason this class switches the active folder
> CD (this.cCurDir)
> ENDPROC
>
> HIDDEN PROCEDURE Error(nError, cMethod, nLine)
> this.cErrMsg=message()
> IF this.logsession
> this.oleMsess.signoff
> ENDIF
> this.logsession = .F.
> ENDPROC
>
> HIDDEN FUNCTION signon
> this.logsession=.T.
local cCurDir
cCurDir = fullpath(CurDir())
> this.oleMsess.signon
cd (cCurDir)
> IF this.logsession
> this.oleMmess.sessionid=this.oleMsess.sessionid
> RETURN .T.
> ELSE
> this.cErrMsg='Unable to Establish a Session ID'
> RETURN .F.
> ENDIF
> ENDFUNC
>
> HIDDEN FUNCTION signoff
> this.oleMsess.signoff
> this.oleMmess.sessionid=this.oleMsess.sessionid
> ENDFUNC
>
> PROCEDURE AddAttachment(tcFilePath, tcName)
> *Appends the filename and a friendly name within angle brackets
> this.cattachments=this.cattachments+IIF(!EMPTY(this.cAttachments),[,],[])+ALLTRIM(tcFilePath)+[ <]+ALLTRIM(tcName)+[>]
> ENDPROC
>
> HIDDEN procedure BindAttachments
> *Adds the attachments to the message
> LOCAL i,filestring,filepath,filename
> FOR i = 0 TO GETWORDCOUNT(this.cattachments,[,])-1
> filestring=GETWORDNUM(this.cattachments,i+1,[,])
> IF !EMPTY(filestring)
> filepath=ALLTRIM(LEFT(filestring,AT([<],filestring)-1))
> filename=STREXTRACT(filestring,[<],[>])
> IF EMPTY(filename)
> filename=JUSTFNAME(filepath)
> ENDIF
> WITH this.olemmess
> .AttachmentIndex=i
> .AttachmentPathName=filepath
> .AttachmentName=filename
> ENDWITH
> ENDIF
> ENDFOR
> ENDPROC
>
> PROCEDURE send
> *This is the primary method.
> *Please set all exposed properties before calling this method
> IF this.signon()
> this.oleMmess.compose
this.oleMmess.RecipIndex = this.oleMmess.RecipCount
this.oleMmess.RecipDisplayName = 'SomeOne@SomeWhere.com'
this.oleMmess.RecipType = 1
this.oleMmess.ResolveName
> this.oleMmess.msgnotetext=this.cBody
> this.oleMmess.msgsubject=this.cSubject
> this.oleMmess.msgnotetext=this.cbody
> this.bindattachments()
> this.oleMmess.send(IIF(this.lAutoSend,1,0))
> IF this.logsession
> this.signoff()
> ENDIF
> ENDIF
> ENDPROC
>
>ENDDEFINE
>
Gregory