|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
send email from VB with minimum user input, mapi, cdo?I want to add the ability for the user to email an attachment after
generating a report, but I don't want to have to rely on them for much help in setting up the email, a lot of them would have trouble finding their outgoing mail server, whether it requres authentication etc. Is it possible to send mail from VB after looking up the outgoing server and any authentication that may be required from the registry, just asking the user to enter the destination email address? And is there a recommended method for sending email that will work on XP through W7? On Aug 13, 6:13 pm, Mike S <ms***@yahoo.com> wrote:
> I want to add the ability for the user to email an attachment after I went round and round looking for a stable method of opening a users> generating a report, but I don't want to have to rely on them for much > help in setting up the email, a lot of them would have trouble finding > their outgoing mail server, whether it requres authentication etc. > > Is it possible to send mail from VB after looking up the outgoing server > and any authentication that may be required from the registry, just > asking the user to enter the destination email address? > > And is there a recommended method for sending email that will work on XP > through W7? default email client and attaching a file a few years back. I had all kinds of advice from purchasing 3rd party tools, to downloading VBSendMail, to CDO, etc. I tried the MailTo: shell which works fine unless you want to include an attachment. That part doesn't work anymore. Basically I was looking for some code that works like Windows Explorer/My Computer. Highlight a file and click a Send to Mail Recipient option and... Bang! New default email message opens with file attached. I found it here: http://www.mvps.org/emorcillo/en/code/vb6/index.shtml You'll need the olelib.tlb (also on the same page). Add/register/ reference the tlb in your project. Copy the code shown on this web page for sending email attachment to a basic Module. Then, to use it you just Call SendMailToRecipient("C:\mypath\myfilename.xxx"). This uses the exact same dll as windows explorer and the results are identical. Tested and works in XP, Vista and Win 7. Works with every default email client I've seen... Outlook, Livemail, AOL Mail, Outlook Express, Hotmail, etc. Tom Shotgun Thom wrote:
Show quoteHide quote > On Aug 13, 6:13 pm, Mike S <ms***@yahoo.com> wrote: Thanks very much for this Tom,>> I want to add the ability for the user to email an attachment after >> generating a report, but I don't want to have to rely on them for much >> help in setting up the email, a lot of them would have trouble finding >> their outgoing mail server, whether it requres authentication etc. >> >> Is it possible to send mail from VB after looking up the outgoing server >> and any authentication that may be required from the registry, just >> asking the user to enter the destination email address? >> >> And is there a recommended method for sending email that will work on XP >> through W7? > > I went round and round looking for a stable method of opening a users > default email client and attaching a file a few years back. I had all > kinds of advice from purchasing 3rd party tools, to downloading > VBSendMail, to CDO, etc. I tried the MailTo: shell which works fine > unless you want to include an attachment. That part doesn't work > anymore. Basically I was looking for some code that works like > Windows Explorer/My Computer. Highlight a file and click a Send to > Mail Recipient option and... Bang! New default email message opens > with file attached. > > I found it here: http://www.mvps.org/emorcillo/en/code/vb6/index.shtml > > You'll need the olelib.tlb (also on the same page). Add/register/ > reference the tlb in your project. Copy the code shown on this web > page for sending email attachment to a basic Module. Then, to use it > you just Call SendMailToRecipient("C:\mypath\myfilename.xxx"). This > uses the exact same dll as windows explorer and the results are > identical. > > Tested and works in XP, Vista and Win 7. Works with every default > email client I've seen... Outlook, Livemail, AOL Mail, Outlook > Express, Hotmail, etc. > > Tom I was coming to the same conclusion and I couldn't find a way to do exactly what you provided. You saved me a lot of time scouring web sites, very much appreciated. Mike On 8/16/2010 9:15 AM, DotNut wrote:
> Use smtp control from ostrosoft.com, its perfect and small in size. Already solved - the Edanmo code (OLELIB.TLB "Send To/Mail Recipient") recommended by Shotgun Thom works perfectly for my needs: it brings up the default email client with the file I want to send already attached, requiring nothing more than a button click, just the level of user involvement I was looking for. Thanks. |
|||||||||||||||||||||||