![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 34
|
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 |
|
|
|
|
|
#2 |
|
New Member
Join Date: Mar 2002
Posts: 16
|
try
Sub Email() ActiveWorkbook.SendMail recipients:="whatever@whatever.com" End Sub |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
|
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. |
|
|
|
|
|
#4 |
|
New Member
Join Date: Mar 2002
Posts: 34
|
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.
|
|
|
|
|
|
#5 |
|
New Member
Join Date: Mar 2002
Posts: 34
|
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. |
|
|
|
|
|
#6 |
|
New Member
Join Date: Mar 2002
Posts: 34
|
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 |
|
|
|
|
|
#7 |
|
Board Regular
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
|
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. |
|
|
|
|
|
#8 |
|
Board Regular
Join Date: Apr 2002
Location: Cape Town,South Africa
Posts: 234
|
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. |
|
|
|
|
|
#9 |
|
Board Regular
Join Date: Apr 2002
Location: Midlands, UK
Posts: 217
|
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. |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|