Helly Ty,
If your text is in a variable lcText, eg by
lcText = mailtable.mailbody
lcName = persons.Name
You could use lcText = STRTRAN(lcText,"%P", lcName)
You could make use of another feature of VFP called text merging.
Code:
Select customer.name as RecipientName, ;
order.Ordernumber, ;
customer.mail as RecipientMail ;
From Order;
Left join customer on Order.customerid = customer.id;
Where Order.state = "ready" and order.mailsent = .F.;
Into Cursor OrderReadyRecipients
Select OrderReadyRecipients
Scan
TEXT TO lcText TEXTMERGE
Hello, <<OrderReadyRecipients.RecipientName>>
We just wanted to inform you that order # <<OrderReadyRecipients.OrderNumber>> is ready.
ENDTEXT
* Sendmail(OrderReadyRecipients.RecipientMail, lcText)
Endscan
You can also use code expressions, eg <<DATE()>> for todays date.
That'll replace <<OrderReadyRecipients.RecipientName>> with the value of the field OrderReadyRecipients.RecipientName, which should of course exist in the table or cursor OrderReadyRecipients. If you send such mails, you will have a table of recipients you want to loop.
The downside of this is, if users should specify the template text, they would need to specify exactly the right technical expressions, table and field names they won't know. You can stay with %P and %O and other placeholders and could replace them with the appropriate technical <<expression>> first and then use that modified placeholders to fill them with variables, table fields etc. Instead of TEXT..ENDTEXT as given above, you also have a Textmerge() function, which of course is best used, if the template text should not be hardcoded into your program, but should come from a mailbody memo field, for example.
Bye, Olaf.