Microsoft Excel Webinar

Results 1 to 2 of 2

Thread: Send email from vba Word

  1. #1

    Send email from vba Word

    Hi guys, happy New Year!

    I need to program a macro for users to send an email with the opened Word file in attachment.
    Basically, I need the following features:
    - I canít use Outlook exclusively, as users are on different Windows platforms (XP/Windows 7), on different Office versions (from 2000 to 2010) and are not all using Outlook;
    - I need to hard code the recipient email address and the email object;
    - I need to be able to add a customized body;
    - I need to send the Word file in attachment, and NOT in the body;
    - Since users are sending this email from their office or home computer, the smtp server may be their personal supplier.

    I made lots of research and tests on existing methods to send emails from vba Word to find the best method in my case. I may have forgotten some pros/cons for each of them:

    1) Routing slip method:
    Pros:
    - The code will work with all email programs;
    - The document can be sent even if it hasn't been saved.
    Cons:
    - This function was disabled after Word 2003, so Office 2007/2010 canít use it.

    2) Automating Outlook:
    Pros:
    - All or most features of Outlook can be programmed.

    Cons:
    - You need to be absolutely sure that the system that's running your code has Outlook installed;
    - If you want to send the document as an attachment the document needs to have been saved at least once before you can send it. This is because you need a path and filename for the file in the code;
    - If Outlook is not already open when your code runs, this method will also be slower.


    3) Febooti Command line email:
    Pros:
    - Send unlimited number of attachments;
    - Use return codes to check success or failure;
    - Works on all Windows platforms.

    Cons:
    - You need to setup the smtp server of the client.


    4) Using CDO object :
    Pros:
    - It doesn't matter what email program you are using;
    - Works with all Office versions (97Ö2007);
    - You can send any file you like (Word, PDF, PowerPoint, TXT filesÖ);
    - No Security warnings.

    Cons:
    - You need to setup the smtp server of the client;
    - If you want to send the document as an attachment the document needs to have been saved;
    - Canít send in attachment the file while it is opened.


    5) MailEnvelope method:
    Pros:
    - Can setup most features (object, body, to field);
    - Can add an attachment as well;
    - Email appears in your email program.

    Cons:
    - If you want to send the document as an attachment the document needs to have been saved;
    - File is sent within the body of the email.

    6) MailMerge method:
    I havenít investigated this one yet.


    Now, I could possibly use one of those methods with a bit of help!

    I CANNOT use any method that depends on one specific email program (like Outlook) or Windows version (like Routing slip). MailEnvelope gave me excellent results, though I wish I could send the document in attachment only, not within the body! As for CDO, I would be glad to use it if I didnít have to program the smtp server within the code (as it is different for each user), unless there is a way to get the clientís smtp server easily (through some code).

    Any suggestion?

  2. #2
    OK guys, my request doesn't seem to have lots of success, so would you recommend any specific method to send an email from Word that would meet those features:
    - I canít use Outlook as users are on different Windows platforms (XP/Windows 7), on different Office versions (from 2000 to 2010) and are not necessarily using Outlook;
    - I need to hard code the recipient email address and the email subject;
    - I need to be able to add a body;
    - I need to send the Word file in attachment, and NOT in the body;
    - Since users are sending this email from their office or home computer, the smtp server may be their personal supplier (if it has to be set within the sending method).

    Please help, I am completely stuck here!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •