MrExcel Message Board

Go Back   MrExcel Message Board > Question Forums > Excel Questions

Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only.

Reply
 
Thread Tools Display Modes
Old Mar 27th, 2002, 03:10 AM   #1
sam_d1
Board Regular
 
Join Date: Mar 2002
Location: India
Posts: 50
Default

Hi all,
I use the following (Excel VB) code to send email.
But this requires 'OutLook'.
Is there a way to dynamically find (and use) any mail client ?

( It must be possible, because, if I type an e-mail id in a cell and click on that, Excel detects the default mail client of that machine and uses it to send the mail.)

thanks in advance
- sam


==================
Code segment start
==================
Private Sub Send_CommandButton_Click()
Dim OL As Object, MailSendItem As Object
Set OL = CreateObject("Outlook.Application")
Set MailSendItem = OL.CreateItem(olMailItem)
With MailSendItem
.Subject = "Subject"
.Body = "Message"
.To = "abc@xyz.com"
.cc = "abc@xyz.com"
.Send
End With
End Sub

================
Code segment End
================
sam_d1 is offline   Reply With Quote
Old Mar 27th, 2002, 04:05 AM   #2
Matt
Board Regular
 
Join Date: Feb 2002
Location: England
Posts: 212
Default

I have had the same problem so would be interested in any responses.
Matt is offline   Reply With Quote
Old Mar 27th, 2002, 05:36 AM   #3
dk
MrExcel MVP
 
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
Default

Not definitely sure if this will do the job but you may as well give it a go. If it works on machines where Outlook isn't the default mail application then you're onto a winner!

http://support.microsoft.com/default...;EN-US;q238114

You should be able to modify the code to suit your need. If not, then please repost.

Regards,
Dan
dk is offline   Reply With Quote
Old Mar 27th, 2002, 07:53 AM   #4
Matt
Board Regular
 
Join Date: Feb 2002
Location: England
Posts: 212
Default

Dan

Managed to get it to work for Groupwise with a few amendments. However after the mail is sent Excel crashes, also not too sure how to attach a file. But, it is a start, thanks for the link.

Matt
Matt is offline   Reply With Quote
Old Dec 5th, 2003, 12:35 PM   #5
Robb
Board Regular
 
Join Date: Feb 2002
Location: Winnipeg, Manitoba, CANADA
Posts: 130
Default Re: Sending email using default mail client ??

Try this... (got it from someone else, can't remember who??)

Sub GroupWiseSendMail(strLoginName, _
strMailPassword, _
strTo, _
strCC, _
strBCC, _
strSubject, _
strBody, _
strAttachFullPathName)

Dim sCommandOptions As String
Dim ogwNewMessage As GroupwareTypeLibrary.Mail

Const NGW$ = "NGW"

' Set application object reference if needed
If ogwApp Is Nothing Then ' Need to set object reference
DoEvents
Set ogwApp = CreateObject("NovellGroupWareSession")
DoEvents
End If

If ogwRootAcct Is Nothing Then ' Need to log in
' Login to root account
If Len(strMailPassword) Then ' Password was passed - use it
sCommandOptions = "/pwd=" & strMailPassword
Else ' Password was not passed
sCommandOptions = vbNullString
End If
Set ogwRootAcct = ogwApp.Login(strLoginName, sCommandOptions, _
, egwPromptIfNeeded)
DoEvents
End If

' Create new message
Set ogwNewMessage = ogwRootAcct.WorkFolder.Messages.Add _
("GW.MESSAGE.MAIL", egwDraft)
DoEvents


' Start adding recipients
With ogwNewMessage
With .Recipients
.Add strTo, NGW ', egwTo
'.Add strCC, NGW, egwCC ' Don't need this
'.Add strBCC, NGW, egwBCC ' Don't need this
End With

' Get the SUBJECT text
.Subject = strSubject

' Build the BODY text
.BodyText = strBody

' Create Attachment
.Attachments.Add strAttachFullPathName
'.Attachments.Add strFile2
' Send the Mail
On Error Resume Next
' Send method may fail if recipients don't resolve
.Send
DoEvents
On Error GoTo 0
End With

Set ogwNewMessage = Nothing
Set ogwRootAcct = Nothing
Set ogwApp = Nothing
DoEvents

End Sub
__________________
Thanx.
Robb is offline   Reply With Quote
Old Dec 5th, 2003, 12:38 PM   #6
Robb
Board Regular
 
Join Date: Feb 2002
Location: Winnipeg, Manitoba, CANADA
Posts: 130
Default Re: Sending email using default mail client ??

oops, don't forget to make your reference to:
GroupWare Type Library

and your delcarations as folllows:
Private ogwApp As GroupwareTypeLibrary.Application
Private ogwRootAcct As GroupwareTypeLibrary.Account
__________________
Thanx.
Robb is offline   Reply With Quote
Old Dec 5th, 2003, 05:59 PM   #7
Ivan F Moala
MrExcel MVP
 
Ivan F Moala's Avatar
 
Join Date: Feb 2002
Location: Auckland, New Zealand
Posts: 4,209
Default

Have a look here to use your default mailer.......

http://www.xcelfiles.com/Outlook_01.html
__________________
Kind Regards,
Ivan F Moala From the City of Sails
Ivan F Moala is offline   Reply With Quote
Old Dec 5th, 2003, 06:13 PM   #8
Robb
Board Regular
 
Join Date: Feb 2002
Location: Winnipeg, Manitoba, CANADA
Posts: 130
Default Re: Sending email using default mail client ??

Nice Ivan!

How would I send an e-mail using a proxy e-mail address?
__________________
Thanx.
Robb is offline   Reply With Quote
Old Sep 19th, 2005, 07:30 PM   #9
poetographer
New Member
 
Join Date: Sep 2005
Posts: 1
Default

I've gotten great mileage out of the GroupwiseSendMail routine. Unfortunately, now that we've upgraded to 6.5.4, the routine has stopped working and I'm stymied. I don't get any error messages, so I haven't been able to figure out where the problem is.

Anyone else know anything about this?

Thx
poetographer is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 12:42 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
All contents Copyright 1998-2012 by MrExcel Consulting.
diabetic desserts recipes recipes Diabetic Soups Holiday Pizza Recipes Popcorn Recipes Recipes For Microwave Pasta Recipes Casserole Recipes Chili Recipes Curry Recipes Crockpot Recipes Apples Recipes Bread Recipes Vegetarian Recipes Vegetable recipes Desserts Recipes Appetizers Ethnic Recipes Meat Dishes Barbecue Recipes Sauces Recipes Marinade Recipes Low Fat Recipes Frugal Gourmet Kitchen Classics Recipes On The Grill Cook Books Seafood Recipes Cajun Recipes Breads Low Fat Low Fat Breads Bread Machine Recipes Yeast Breads Quick Breads Fat Free Vegetarian Salad Recipes Eggplant Recipes Radish Recipes Tomato Recipes Jalapeno Recipes Potato Recipes Lettuce Recipes Cabbage Recipes Beans Ambrosia Recipes Biscotti Recipes Desserts Low Fat Cookie Recipes Cheesecake Recipes Cake Recipes Pie Recipes Muffin Recipes Custard Recipes Best Appetizers Appetizers Low Fat Salsa Recipes Dip Recipes International Recipes Afghan Recipes Alaska Recipes French Recipes German Recipes Greek Recipes Italian Recipes Spanish Recipes Thai Recipes Korean Recipes Chinese Recipes Mexican Recipes Indian Recipes Beef Recipes Pork Pork & Ham Pork Butts Pork Chop Recipes Pork Ribs Rulled Pork Poultry Recipes Stews Recipes Ground Beef Barbecue Grill Barbecue Smoker All Purpose Sauce BBQ Sauce Barbecue Sauce Carolina BBQ Sauce Pickle Recipes Marinades Smoking Low Fat Appetizers & Dips Low Fat Breakfast Low Fat Cakes Low Fat Cheesecakes Low Fat Cookies Low Fat Desserts Low Fat Fish & Seafood Low Fat Meats Low Fat Pasta Low Fat Pies Low Fat Salads Low Fat Sandwiches Low Fat Sauces & Condiments Low Fat Sides Low Fat Soups Low Fat Vegetarian Baker's Dozen Taste of Home Recipe Book Bon Appetit Cookbook Blacktie Cookbook Buster Cook Book Cookbook USA Cook Book Cook Book Sara's Cookbook Sara's Cookbook Appetizers and Dips Poultry recipes Diabetic recipes Holiday recipes Miscellaneous recipes 110 recipes 1986 Usenet cookbook 2900 recipes Cyberrealm recipes Great sysops of world Specialty recipes Ceideburg recipes Cheese recipes Chili recipes Fruits recipes Garlic recipes Great chefs of NY Londontowne recipes Raisins recipes Recipes for kids US Food Vegetarian recipes Bread recipes Drinks Meat Dishes Brisket recipes Caribou recipes Chicken recipes Filet mignons recipes Pork recipes Swordfish recipes Turkey recipes Pasta recipes Uncategorized recipes Ethnic recipes Canada recipes English recipes Ethiopia recipes Germany recipes Greece recipes Mexican recipes Philippines recipes Welsh recipes Microwave recipes Soups recipes Vegetable recipes Asparagus recipes Barley recipes Brown rice recipes Lentil recipes Mushrooms recipes Salads recipes Wild rice Desserts recipes Cakes recipes Chocolate recipes Cookies recipes Ice cream recipes