+ Reply to Thread
Results 1 to 12 of 12

Sending Email Dependent on Default Email Client

  1. #1
    Forum Contributor
    Join Date
    01-18-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    127

    Sending Email Dependent on Default Email Client

    Hi there, I've created a userform which is being used by different people. When the userform has been filled out, on the click of a commandbutton I'm trying to get Excel to automatically bring the 'save as' window up to save the workbook, and then, once the user has sorted their file name and directory and clicked save, to attach the current workbook to their default email agent.

    The trouble is that I need a bit more than the sendmail command offers. I need the email to contain a body as well as a subject, and obviously the attachment, and I need the email to display rather than automatically send (so the user can add anything if they want).

    I'm fine for code doing all this in outlook. But some users are using Lotus Notes.

    Does anyone know reliable code for determining the default email client and going from there?

  2. #2
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Sending Email Dependent on Default Email Client

    Truth be told if you want it for any mail client I'm not sure how trivial it will be.

    Adding the attachment to the mail item is the tricky part given the code will vary by mail client ... if you sent only the link to the attachment it might be viable via a mailto url.

    Maybe some of the other guys will have some ready made code available...
    Last edited by DonkeyOte; 04-30-2010 at 08:01 AM. Reason: meant mail client not browser - doh !

  3. #3
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Sending Email Dependent on Default Email Client

    Having re-read your post perhaps you're concerned only with two clients - namely Outlook and Lotus Notes... in which case you might find you can determine the client and act accordingly - perhaps along the lines of:

    Please Login or Register  to view this content.
    obviously the MsgBox items would be replaced with calls to appropriate routines.

    Whether you would need to use late binding for your code I don't know ?
    (ie would Lotus client debug if using early binding with OL library or is OL library available by standard with Office irrespective of client installation)

    There are plenty here with Lotus experience who can offer more insight I'm sure.

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Sending Email Dependent on Default Email Client

    Not sure if this earlier post, see Leith's code, will help. maybo, you could use CDO
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  5. #5
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Sending Email Dependent on Default Email Client

    I'm not sure CDO would allow you to display the mail item (as opposed to send)

  6. #6
    Forum Contributor
    Join Date
    01-18-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    127

    Re: Sending Email Dependent on Default Email Client

    Thanks Donkey ote, Roy,

    I'll use the client determining code as a foundation and build on that.

    In regards to setting up the mail but not sending, I have found some general code for the setting up and sending which ends in the following:

    Please Login or Register  to view this content.
    I was thinking of simply leaving out the second half of the code so that the email opens and displays with everything ready, but doesn't send.

    Would that work?

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: Sending Email Dependent on Default Email Client

    Outlook has a .Display method you can use instead of .Send

    not sure about Lotus notes.
    Cheers
    Andy
    www.andypope.info

  8. #8
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Sending Email Dependent on Default Email Client

    Andy, to sate my curiosity...

    Do you know if the OL library will be available irrespective of the installed mail client if any other Office apps are installed ?
    By that I mean: if I ran Lotus Notus but had MS Excel installed would the OL library be available ?
    (just trying to ascertain for future ref. if code dependent upon early binding would compile on say a Lotus client)

    edit: for the record I'm neither advocating nor dismissing early binding - just curious

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,434

    Re: Sending Email Dependent on Default Email Client

    I could not say for certain. But I would image that if your email client was Lotus Notes you, or the IT. dept, would not bother installing Outlook. So the library would probably not be available.

  10. #10
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Sending Email Dependent on Default Email Client

    Thanks Andy.

    Julesdude, based on the above I'd say that if you do opt for an either/or routine you should avoid being reliant on Early Binding on the Outlook side of things.

  11. #11
    Forum Contributor
    Join Date
    01-18-2010
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    127

    Re: Sending Email Dependent on Default Email Client

    Thanks to you both.

    Donkeyote - you'll have to dumb it down a bit for me I'm afraid early binding?

  12. #12
    Forum Guru DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Northumberland, UK
    MS-Off Ver
    O365
    Posts
    21,531

    Re: Sending Email Dependent on Default Email Client

    The general principles of Early vs Late Binding in VBA are outlined here: http://word.mvps.org/faqs/interdev/e...atebinding.htm

    If you have referenced the Outlook Library explicitly (VBE -> Tools -> References) then the chances are you're using Early Binding in your Outlook code.
    The problem with Early Binding is when you distribute the file to a client PC which does not have the library you referenced available to it - it will be listed as :MISSING and will cause "issues".

    Late Binding is slower to execute than Early Binding, however, the code should not generate any "issues" even if OL is not installed on the client (this assumes that the OL code is not invoked on a machine running Lotus Notes).

    Other alternatives (to maintain Early Binding) would be to add/remove the appropriate OL Library upon the workbook Opening / Closing (where mail client is OL).
    This too assumes the OL code is never invoked on a Lotus client.

    To be clear though - most would opt for late binding where there is the potential for missing libraries across client PCs.

    I hope that makes some sense ?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1