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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

message body with Outlook Express with Mapi object

Status
Not open for further replies.

vbenlieva

Programmer
May 7, 2005
10
BG
I use Vfp 9.0 and Outlook Express (with a Mapi object)
I want to copy text from a Word document and paste it in the mail body. My word document is stored in a General field. Here is the code:

IF thisform.logsession=.t. && Check if the user was able to login
SELECT Mytable
keyboard '{Ctrl+C}{Ctrl+W}' plain clear
modi general ('Mytable.MyWordDoc') && The Word document is in the Clipboard now

thisform.OleMMess.sessionID=thisform.OleMSess.sessionID
thisform.OleMMess.compose()
thisform.OleMMess.MsgNoteText=_CLIPTEXT && I want to place the Word doc in the message body

thisform.OleMMess.msgindex=-1
thisform.OleMMess.msgsubject="the subject"

merror=0
ON ERROR do errormsg with merror
thisform.OleMMess.send(.t.)
ON ERROR
thisform.OleMSess.signoff
ENDIF

The problem is that it doesn't paste the text in the message body. Any idea?
Thanks in advance
 
My guess is it's because _CLIPTEXT doesn't contain the message. Because you have copied from Word, the clipboard will contain a rich-text object. _CLIPTEXT can only hold plain text, so it will never receive what you pasted into Word.

Is there are any reason why you can't set .MsgNoteText directly to the contents of the Word document, which you can access via a Range object. Doing it via KEYBOARD commands and the clipboard seems to be asking for trouble.

In fact, it would be even better if you could avoid the General field, and do the whole thing via Word Automation (which includes as "send to email recipient" method).

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Code:
Declare Long GlobalLock in Win32API Long hMem
Declare Long GlobalUnlock in Win32API Long hMem
Declare Long GlobalSize in Win32API Long hMem
Declare String lstrcpy in Win32API String @ lpDest, Long lpSrc
Declare Long OpenClipboard in Win32API Long
Declare Long CloseClipboard in Win32API
Declare Long RegisterClipboardFormat in Win32API String
Declare Long GetClipboardData in Win32API Long uFormat

s = ""
cf = RegisterClipboardFormat("Rich Text Format")
If(OpenClipboard(0) != 0)
    h = GetClipBoardData(cf)
    If h > 0
	    len = GlobalSize(h)
	    s = Replicate(Chr(0), len)
	    ptr = GlobalLock(h)
	    lstrcpy(@s, ptr)
	    s = Left(s, len-1)
	    GlobalUnlock(h)
    EndIf
    CloseClipboard()
EndIf

? s

From Message #709952 in UT by Alexander Golovlev.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top