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 May 14th, 2002, 07:47 AM   #1
matthewh
New Member
 
Join Date: Mar 2002
Posts: 34
Default

Can anyone tell me how to email direct from Excel using Outlook 2000 MAPI - ie so I can get the user to hit a button and the active sheet gets mailed as an attachment to 2 people - one as a BCC - without any further intervention. The only way I can see for now is...

Application.Dialogs(xlDialogSendMail).Show

Thanks
matthewh is offline   Reply With Quote
Old May 14th, 2002, 08:14 AM   #2
nuozek
New Member
 
Join Date: Mar 2002
Posts: 16
Default

try

Sub Email()
ActiveWorkbook.SendMail recipients:="whatever@whatever.com"
End Sub
nuozek is offline   Reply With Quote
Old May 14th, 2002, 09:33 AM   #3
Iain Lewis
Board Regular
 
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
Default

Try this :

Sub aaa()
Dim OL As Object, MailSendItem As Object
Set OL = CreateObject("Outlook.Application")
Set MailSendItem = OL.CreateItem(olMailItem)
ActiveSheet.Copy
ChDir "C:WINNTTemp"
ActiveWorkbook.SaveAs FileName:="C:WINNTTemptempBook.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False _
, CreateBackup:=False
filepath = ActiveWorkbook.Path
actfilename = ActiveWorkbook.Name
sendfile = filepath & "" & actfilename
With MailSendItem
.Subject = ""
.Body = ""
.To = ""
.BCC = ""
.Attachments.Add (sendfile)
.Send
End With
ActiveWorkbook.Close
Kill "C:WINNTTemptempBook.xls"
End Sub

This copies the activesheet to a new book. The new book is saved to the temp folder ( in this case in WINNT - change to suite system / user requirements ).

It then creates a new email - put what ever you need for Subject, Body etc between the "".

Finally it closes the "new" file & deletes it from the place it was saved.
Iain Lewis is offline   Reply With Quote
Old May 16th, 2002, 01:56 AM   #4
matthewh
New Member
 
Join Date: Mar 2002
Posts: 34
Default

iAN lEWIS - THANKS. iNTERESTING APP - I THINK IT'S WHAT I'M LOOKING FOR, BUT IT COMPLAINED THAT A COUPLE OF VARIABLES WERN'T DECLARED-filepath, actfilename, sendfile - CHANGED THAT - NOW IT COMPLAINS THAT THERE'S A PATH ERROR(75). THIS IS TO DO WITH ACCESSING READ-ONLY FILES OR THE OS CAN'T ACCESS THE PATH FOR SOME REASON. cAN YOU SHED ANY LIGHT? I HAVE OUTLOOK LIBRARIES AVAILABLE TO XL IN THE REFERENCES.
matthewh is offline   Reply With Quote
Old May 16th, 2002, 02:02 AM   #5
matthewh
New Member
 
Join Date: Mar 2002
Posts: 34
Default

aaaaaaaaaaaRRRRRRRRRRRRRGGGGGGGGGGGHHHHHHHH!!!! *&^%$£!!!!!

IAN, I FANALLY GET IT WORKING AND THEN....

FILE DELETED
------------

Antigen for Exchange removed tempBook.xls since it
was found to be infected with W97M/MailWorm.Variant.Worm (CA(InoculateIT)) virus.


matthewh is offline   Reply With Quote
Old May 16th, 2002, 02:13 AM   #6
matthewh
New Member
 
Join Date: Mar 2002
Posts: 34
Default

My appologies - can't remember who it was, someone sent me a post with a sub called sendrange.

I've tried it but only get and error box with a very descritive '400' diplayed. So what's that all about then? Press help and you get a not-so-helpful grey blank window.

Can you help?

Matt
matthewh is offline   Reply With Quote
Old May 17th, 2002, 02:59 AM   #7
Iain Lewis
Board Regular
 
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
Default

Hi Matthew,

Not sure what has been going wrong with the code - it's something I wrote for someone else & both he & I have not had these problems. What system are you on ?

If you want email me & I'll send you the file with the macro in.
Iain Lewis is offline   Reply With Quote
Old May 17th, 2002, 06:03 AM   #8
gareth
Board Regular
 
Join Date: Apr 2002
Location: Cape Town,South Africa
Posts: 234
Default

Absolutely right

It worked for me.Maybe his settings is wrong,what do you think?

Maybe he should try this for kicks :

Sub EMAIL1()

Mailee = InputBox("Please Enter Name to Send sheet to.........")
subj = InputBox("Please enter eMail Subject..............")
Application.Dialogs(xlDialogSendMail).Show arg1:="", arg2:="Here is the sheet as Requested"


End Sub


============
Have fun with it.
__________________
Regards
Gareth
Visit The Excel Maniacs :<>: Have a Chat! :<>: Free Stuff!
gareth is offline   Reply With Quote
Old May 22nd, 2002, 01:24 AM   #9
Iain Lewis
Board Regular
 
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
Default

One problem I've found with the code code above is that it only works with Outlook 2000. The "fix" I've found is to add a .DDL file called MS09.DLL. You will also need to add the refernce to the .DLL to the VBA Reference library.

Feel free to send a person email if you'd like more details.
Iain Lewis 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 05:55 AM.


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