Thanks very much. Looking at your code has helped, but I still have some issues...
1) The e-mail message does not automatically get sent. Instead, my message comes up in Outlook and I have to manually click on "Send" to send it.
2) Even though the recipient name is underlined, like it has been resolved OK, I promptly get mail back from System Administrator stating: Your message did not reach some or all of the intended recipients. The following recipients could not be reached: 'Chuck Henry' on 9/3/99 3:42 PM No transport provider was available for delivery to this recipient.
3) An attachment icon shows up in the message, but there doesn't seem to be a real file there. It does nothing when I double-click on it, or when I right-click it and choose an action from the context menu.
Here is my code as of now...
ThisForm.AddObject("Session1","olecontrol","MSMAPI.MAPISession")
ThisForm.AddObject("Message1","olecontrol","MSMAPI.MAPIMessages")
ThisForm.Session1.SignOn
ThisForm.Message1.SessionId = ThisForm.Session1.SessionId
ThisForm.Message1.Compose
ThisForm.Message1.RecipIndex = 0
ThisForm.Message1.RecipDisplayName = "CHUCK HENRY"
ThisForm.Message1.ResolveName
ThisForm.Message1.MsgSubject = "Change Order " + Ord_Ma(2)
ThisForm.Message1.MsgNoteText = "Electronic Change Order Text file for Order Number: " + Ord_Ma(2)
ThisForm.Message1.AttachmentPathname = "ChgOrder.txt"
ThisForm.Message1.Send(1)
ThisForm.RemoveObject("Session1","olecontrol","MSMAPI.MAPISession")
ThisForm.RemoveObject("Message1","olecontrol","MSMAPI.MAPIMessages")
>This is code from a class I have for MAPI stuff. I instantiate the session and message objects in the init of the class like this:
>
>This.oSession = CreateObject('MSMAPI.MAPISession')
>This.oMessage = CreateObject('MSMAPI.MAPIMessages')
>
>Then I have properties for all the parts of a message and programmatically set them before calling a custom Send method. The send method is as follows:
>
>*set step on
>
>WAIT WINDOW NOWAIT "Please wait ... Logging Into Mail"
>
>* Signon to mail
>IF !This.lLoggedIn AND !EMPTY(This.cProfile)
> This.oSession.UserName = This.cProfile
> This.oSession.Signon
> This.lLoggedIn = .T.
>ELSE
> RETURN .F.
>ENDIF
>
>* If the session ID is not valid, do not go any further
>IF This.oSession.SessionID > 0
> This.oMessage.SessionID = This.oSession.SessionID
>ELSE
> WAIT WINDOW NOWAIT "Login Failed"
> RETURN .F.
>ENDIF
>
>* Start a new message
>This.oMessage.Compose
>* Increment the Recipient index
>This.oMessage.RecipIndex = 0
>
>* Set the Recipient name and resolve
>IF EMPTY(This.cSendTo)
> RETURN .F.
>ENDIF
>
>This.oMessage.RecipDisplayName = This.cSendTo
>This.oMessage.ResolveName
>
>IF !EMPTY(This.cSubject)
> This.oMessage.MsgSubject = This.cSubject
>ENDIF
>
>IF !EMPTY(This.cText)
> This.oMessage.MsgNoteText = This.cText
>ENDIF
>
>IF !EMPTY(This.cAttachment)
> This.oMessage.AttachmentPathname = This.cAttachment
>ENDIF
>
>WAIT WINDOW NOWAIT "Sending Message ... "
>
>This.oMessage.Send(0)
>
>WAIT WINDOW NOWAIT "Message Sent!"
>RETURN .T.
>
>You should be able to get the idea from this, if not feel free to write back. If anyone thinks it is useful, let me know and I'll submit the class to UT. The thing I liked about my approach (other than it was mine <g>) was it encapsulated the mechanics of the 2 objects into one ie Message and Session were rolled into one object which is the way I think of MAPI anyway.
>
>"Coles Law: Thinly sliced cabbage"
>This is code from a class I have for MAPI stuff. I instantiate the session and message objects in the init of the class like this:
>
>This.oSession = CreateObject('MSMAPI.MAPISession')
>This.oMessage = CreateObject('MSMAPI.MAPIMessages')
>
>Then I have properties for all the parts of a message and programmatically set them before calling a custom Send method. The send method is as follows:
>
>*set step on
>
>WAIT WINDOW NOWAIT "Please wait ... Logging Into Mail"
>
>* Signon to mail
>IF !This.lLoggedIn AND !EMPTY(This.cProfile)
> This.oSession.UserName = This.cProfile
> This.oSession.Signon
> This.lLoggedIn = .T.
>ELSE
> RETURN .F.
>ENDIF
>
>* If the session ID is not valid, do not go any further
>IF This.oSession.SessionID > 0
> This.oMessage.SessionID = This.oSession.SessionID
>ELSE
> WAIT WINDOW NOWAIT "Login Failed"
> RETURN .F.
>ENDIF
>
>* Start a new message
>This.oMessage.Compose
>* Increment the Recipient index
>This.oMessage.RecipIndex = 0
>
>* Set the Recipient name and resolve
>IF EMPTY(This.cSendTo)
> RETURN .F.
>ENDIF
>
>This.oMessage.RecipDisplayName = This.cSendTo
>This.oMessage.ResolveName
>
>IF !EMPTY(This.cSubject)
> This.oMessage.MsgSubject = This.cSubject
>ENDIF
>
>IF !EMPTY(This.cText)
> This.oMessage.MsgNoteText = This.cText
>ENDIF
>
>IF !EMPTY(This.cAttachment)
> This.oMessage.AttachmentPathname = This.cAttachment
>ENDIF
>
>WAIT WINDOW NOWAIT "Sending Message ... "
>
>This.oMessage.Send(0)
>
>WAIT WINDOW NOWAIT "Message Sent!"
>RETURN .T.
>
>You should be able to get the idea from this, if not feel free to write back. If anyone thinks it is useful, let me know and I'll submit the class to UT. The thing I liked about my approach (other than it was mine <g>) was it encapsulated the mechanics of the 2 objects into one ie Message and Session were rolled into one object which is the way I think of MAPI anyway.
>
>"Coles Law: Thinly sliced cabbage"
Chuck Henry