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 23rd, 2002, 09:02 AM   #1
poleary2000
Board Regular
 
Join Date: Apr 2002
Location: Pittsburgh, PA
Posts: 317
Default

Hello all. Is it possible to due the following?

I have three cells. Inside these cells will be a persons name (or it will be blank). If there is a name in the cell I want the active sheet to be emailed to the name in the cell. But I would like it to e-mail to the first intial + last name@acme.com.

Example: Name = John Doe

Active sheet is sent to jdoe@acme.com

It would then send the sheet to all three (or how ever many) names.

Is this possible? If so, anyone have any quick code to do it?

__________________
Thanks in advance,
Patrick
poleary2000 is offline   Reply With Quote
Old May 23rd, 2002, 09:04 AM   #2
poleary2000
Board Regular
 
Join Date: Apr 2002
Location: Pittsburgh, PA
Posts: 317
Default

I would like to send the active sheet as an attachment. Sorry for neglecting to include that.
poleary2000 is offline   Reply With Quote
Old May 23rd, 2002, 09:09 AM   #3
Mark O'Brien
MrExcel MVP
 
Mark O'Brien's Avatar
 
Join Date: Feb 2002
Location: Columbus, OH, USA
Posts: 3,519
Default

Something like this should work:


Dim sEmail As String

With Sheets("Sheet1")
sEmail = Mid(.Range("A1").Value, 1, 1) & .Range("A2").Value & "@acme.com"
End With

ThisWorkbook.SendMail Recipients:=sName, Subject:="Blah"


HTH

(I haven't tested this, but it should work)
__________________
Mark O'Brien

Columbus Ohio Celtic Supporters Club
Mark O'Brien is offline   Reply With Quote
Old May 23rd, 2002, 09:12 AM   #4
poleary2000
Board Regular
 
Join Date: Apr 2002
Location: Pittsburgh, PA
Posts: 317
Default

I believe this will send the entire work book as an attachment?? I would like to send just the active worksheet as an attachment.


__________________
Thanks in advance,
Patrick
poleary2000 is offline   Reply With Quote
Old May 23rd, 2002, 09:18 AM   #5
dk
MrExcel MVP
 
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
Default

Hello,

This should work:-

Code:
Sub SendSheet()
Dim strEmailAdd As String, lngRow As Long
'Assume that addresses are in A1:A3

For lngRow = 1 To 3
    If Cells(lngRow, 1) <> "" Then
        strEmailAdd = Left(Cells(lngRow, 1), 1) & Right$(Cells(lngRow, 1), Len(Cells(lngRow, 1)) - InStr(1, Cells(lngRow, 1), " ")) & "@acme.com"
        ActiveSheet.Copy
        ActiveWorkbook.SendMail strEmailAdd, "Your copy of worksheet x"
        ActiveWorkbook.Close False
    End If
Next lngRow
End Sub
HTH,
Dan
dk is online now   Reply With Quote
Old May 23rd, 2002, 11:05 AM   #6
poleary2000
Board Regular
 
Join Date: Apr 2002
Location: Pittsburgh, PA
Posts: 317
Default

poleary2000 is offline   Reply With Quote
Old May 23rd, 2002, 11:07 AM   #7
poleary2000
Board Regular
 
Join Date: Apr 2002
Location: Pittsburgh, PA
Posts: 317
Default

DK,

Great suggestion!

Your solution...does it send three different e-mails? Can it be changed to send just one e-mail with three recipients? Also, I made a mistake in my first post. The names will actually look like this inside the cells:

Doe, John

I see that your concatentation formula is very complicated. Can you rewrite it for me to account the the last minue quirk I just through in? I apologize for the inaccurate information.

Thanks for your help so far.
__________________
Thanks in advance,
Patrick
poleary2000 is offline   Reply With Quote
Old May 23rd, 2002, 11:40 AM   #8
dk
MrExcel MVP
 
Join Date: Feb 2002
Location: Sydney, Australia
Posts: 2,908
Default

Hello,

This should be what you need. Let me know if not. I've tried to make the code a bit more readable as well.


Dan

Code:
Sub SendSheet()
Dim strRecipients(1 To 3), lngRow As Long, strAdd As String, strCell As String
'Assume that addresses are in A1:A3

For lngRow = 1 To 3

    strCell = Cells(lngRow, 1)

    If strCell <> "" Then

        strAdd = Mid(strCell, InStr(1, strCell, " ") + 1, 1)    'Gets the J of Doe, John
        strAdd = strAdd & Left$(strCell, InStr(1, strCell, ",") - 1) 'Makes it JDoe
        strAdd = strAdd & "@acme.com"    'Makes it JDoe@Acme.com
        strRecipients(lngRow) = strAdd
    End If
Next lngRow

ActiveSheet.Copy
ActiveWorkbook.SendMail strRecipients, "Your copy of worksheet x"
ActiveWorkbook.Close False


End Sub
dk is online now   Reply With Quote
Old May 23rd, 2002, 11:54 AM   #9
poleary2000
Board Regular
 
Join Date: Apr 2002
Location: Pittsburgh, PA
Posts: 317
Default

Thanks a million!
poleary2000 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 08:01 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