can a .doc or .docx file be send through an email in the attachment?

Posted on 2008-11-04
Last Modified: 2012-05-05

i have a .doc file (file attached ). is that possible when user finish filling out the information, the user can just click the sumbit and sent the file as an email attachemnt to me?

Thank you so much for your suggestion!!

Question by:lilyyan
    LVL 7

    Assisted Solution


    there are couple of different way
    you can use the normal web form to get the user data and when user submit at that time on server create word document object and create document or you can create word document template and then use that template to create the final document and then use CDONT mail object to send mail to you

    Author Comment

    thank you for your reply!

    could you please be more specific about the different ways?

    is there a built-in function in MS Word that can send the file as an email attachment ?

    i'm using php. is that possible you may post a php sample, so i could better understand the process?

    thank you so much !!
    LVL 7

    Assisted Solution

    the best and fast way to generate and send the word document is
    generate HTML document and then rename it to .doc and it will open up as word doc with all formatting

    send email using PHP -

    Author Comment

    could you please have an example for :

    >>the best and fast way to generate and send the word document is
    generate HTML document and then rename it to .doc and it will open up as word doc with all formatting

    i'm kind of still not sure :-)) thank you so much!!
    LVL 7

    Accepted Solution

    once user submit the data, generate the HTML file as below then rename it to .doc extension and then send it as attachment

    for test save the below code as .doc file and then open the file in word, it is very easy

    <table><tr><td><b>Requested Visit Date</b></td><td></td></tr>
    <tr><td>Start Time</td><td>End Time</td></tr>

    Open in new window


    Author Comment

    well, here is several steps involved here

    1. generate the HTML  // how to do this step in php

    2. rename it to .doc extension . // same question as above

    3.  then send it as attachment. // well, the link you posted is for text and html attachment in php, not for .doc file

    thank you so much for your reply!! : )
    LVL 7

    Assisted Solution

    Please follow the below link to generate HTML .doc file, no need to rename the file
    file create --- here instead of creating .txt file create .doc file, also manipulate the myText code where in it writes the myText textbox content to file, instead of that write HTML tag like
    "<html><body><table><tr><td><b>Requested Visit Date</b></td><td>.......CONCATE your other tag and data here

    Email - for email with attachment use "Sending Email with Attachment" section
    of send email using PHP -
    and modify the attachment code
    //and split it into smaller chunks
    $attachment = chunk_split(base64_encode(file_get_contents('')));

    or use


    Author Comment

    Really appreciate you reply! yet it's a little too completed ... : )

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Preface: When I started this series, I used the term CommandBars because that is the Office Object class that it discusses. Unfortunately, when Microsoft introduced Office 2007, they replaced the standard Commandbar menus with "The Ribbon" and rem…
    JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
    The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now