Page 1 of 3

I require some work done - eMail Merge Feature

Posted: Tue Jul 15, 2008 8:55 am
by Ollie
Hi guys,

I have written a small database application with FWH and xHarbour. Its a basic CRM and quoting system.

I need to add the functionaliy to be able to send bulk emails to the database by merging certain datafields.

i.e. Dear <<title>> <<surname>> etc.

Where I need the help is the editor - I would like the user to be able to create the email within the program. (Change fonts, insert pics etc.)

Naturally, I am prepared to pay for the feature or the components that can enable the feature to be added into my program.

You can contact me on: ollie @ theoasis.co.za

Re: I require some work done - eMail Merge Feature

Posted: Tue Jul 15, 2008 10:15 am
by Enrico Maria Giordano
You can use Word.

EMG

Posted: Tue Jul 15, 2008 10:41 am
by Ollie
I'm sure I could. Could it still be done within the confines of my program?

OLE etc?

I need more guidance on this. Sample code etc. If I had the time, I could possibly figure it out, but I need a solution quickly.

Could you elaborate on the solution you suggest?

Posted: Tue Jul 15, 2008 11:58 am
by Enrico Maria Giordano
This is a working sample:

Code: Select all

FUNCTION MAIN()

    LOCAL oWord := CREATEOBJECT( "Word.Application" )

    LOCAL oDoc := oWord:Documents:Add()

    LOCAL oSel

    oDoc:Range:InsertAfter( "<toreplace>" + CHR( 13 ) )

    oDoc:Select()

    oSel = oWord:Selection

    WORDREPLACE( oSel, "<toreplace>", "Giordano Enrico Maria" )

    oWord:Visible = .T.

    RETURN NIL


FUNCTION WORDREPLACE( oSel, cSrc, cRpl )

    oSel:Start = 0
    oSel:End = -1

    oSel:Find:Execute( cSrc )

    oSel:Range:Text = cRpl

    RETURN NIL
EMG

Posted: Tue Jul 15, 2008 12:15 pm
by Ollie
Wow! Thats was easy!

Where can I find other commands to:

1. Open an exisiting document to do the replace on.

Thanks so far!

Posted: Tue Jul 15, 2008 12:36 pm
by Enrico Maria Giordano
Search you hard disk or the Office CD for vba*.chm.

EMG

Posted: Wed Jul 16, 2008 8:43 am
by Horizon
Hi Enrico,

is it possible to give an easy example that opens a word document and print it.

Thanks,

Posted: Wed Jul 16, 2008 11:13 am
by Enrico Maria Giordano

Code: Select all

FUNCTION MAIN()

    LOCAL oWord := CREATEOBJECT( "Word.Application" )

    LOCAL oDoc := oWord:Documents:Open( "E:\XHARBOUR\TEST.DOC" )

    oDoc:PrintOut( .F. )

    oDoc:Close( 0 )

    oWord:Quit()

    RETURN NIL
EMG

Posted: Wed Jul 16, 2008 11:35 am
by Horizon
Thanks Enrico,

It works very well.

Posted: Wed Jul 16, 2008 11:42 am
by Ollie
Thank you. This is all very helpful.

1. How would you do a Email merge though? Surely not with Word?

2. And on the subject of merging with Word, how would you get it to replicate the document for each record in the Database

e.g. Dear Mr Jones
Bla Bla
----- New Page -----
Dear Mr Smith
Bla Bla
----- New Page -----
etc.

Posted: Wed Jul 16, 2008 12:01 pm
by Enrico Maria Giordano
Ollie wrote:2. And on the subject of merging with Word, how would you get it to replicate the document for each record in the Database
Use InsertFile() method.

EMG

Posted: Wed Jul 16, 2008 1:30 pm
by Ollie
You are a man of few words. :)

Is your response related to the Email part of my question or my "replicate" letter part of the email?

You are clearly knowledgable on the subject, and I clearly need a little more guidance. I appreciate that a forum such as this one is there to help each other on a community basis, but I need more specific help / code and am prepared to pay for your time.

As I've said I need to 1. Create an email template and 2. Send an email to the database using this template. (Using Office together with my software to achieve this is fine)

If you can help, please email me on ollie @ theoasis.co.za or on Skype Chat - ollieoasis

Thanks.

Posted: Wed Jul 16, 2008 3:21 pm
by Enrico Maria Giordano
Ollie wrote:You are a man of few words. :)
Yes, always. :-)
Ollie wrote:Is your response related to the Email part of my question or my "replicate" letter part of the email?
It is the answer to your point 2, as you can see in my quoting inside my previous message.
Ollie wrote:As I've said I need to 1. Create an email template and 2. Send an email to the database using this template. (Using Office together with my software to achieve this is fine)
Sorry, I don't know how to send emails from Word.

EMG

Posted: Wed Jul 16, 2008 3:27 pm
by Ollie
It doesn't have to be from word. Is there another way to do it? I need the user to be able to design an email (nothing too fancy - basic functionality as in an Outlook express etc.) and then have that email sent to the database.

So I guess its an HTML Editor that I need that can plug in neatly into my app. Or is there a better way?

Posted: Wed Jul 16, 2008 3:33 pm
by Enrico Maria Giordano
I don't know, sorry.

EMG