+ Reply to Thread
Results 1 to 4 of 4

A real challenge

  1. #1
    Registered User
    Join Date
    09-25-2004
    Posts
    2

    A real challenge

    I am looking to do something a bit clever using Excel and OutlookXP and need help with the code, i hope one of you smart chaps can help me out.

    I would like to send a standard email saved somewhere (suggestions?) - and an attachment - to a recipient. I will be taking email addresses down in cell "A1" of my spreadsheet and i want a macro that will send the email and attachment to the recipient whose address will be in "A1"

    If anyone could provide the code to do this that would be great.

    Regards,

    Tompy

  2. #2
    Forum Contributor
    Join Date
    11-29-2003
    Posts
    1,203
    Open the file that has the list of names.

    Turn on the macro recorder (tools > macro > record)

    click on the first name in the list

    hold down the Ctrl key and press the down arrow

    open the file you want as an attachment

    select File > Send to

    turn off the macro recorder

    go into VBE (tools > macro > visual basic editor) or press F11

    change the command that says: Selection.End(xlDown).Select
    To say something like: lastRow = Range("A1").End(xlDow).Row

    use that to create a loop

    for myRow = 2 to lastRow

    Next myRow

    inside the loop put the command for the File > Send to

    you should not have to open the attachment file every time

    - Pete

  3. #3
    Registered User
    Join Date
    09-25-2004
    Posts
    2
    Thanks Pete

    That makes sense but my code knowledge is not good enough to set up the loop and to talk to Outlook - I was hoping someone could provide the full code, i can adapt it to the right references once i have it, but i have never seen a working version which is what i will use as a template,

    Regards,

    Marcus

  4. #4
    Valued Forum Contributor Charles's Avatar
    Join Date
    02-10-2004
    Location
    Biloxi
    MS-Off Ver
    Windows 7, Excel 2003,2007 & Mac2011
    Posts
    845
    This may help.

    Sub sendmymail()
    ''' This will send the workbook along with macros ''''
    ActiveWorkbook.HasRoutingSlip = True
    With ActiveWorkbook.RoutingSlip
    .Delivery = xlOneAfterAnother
    .Subject = "Your Subject Here"
    .Message = "Your Mesage here"
    .Recipients = Worksheets("Sheet1").Range("A1").Text
    .ReturnWhenDone = False
    ActiveWorkbook.Route
    End With
    End Sub
    Sub sendwithoutmacro()
    '' This will send workbook with out macros it sends a copy of the sheet you want to send ''

    Sheets("Sheet1").Select '''create the work sheet to be sent
    Sheets("Sheet1").Copy

    ActiveWorkbook.HasRoutingSlip = True
    With ActiveWorkbook.RoutingSlip
    .Delivery = xlOneAfterAnother
    .Subject = "Your Subject Here"
    .Message = "Your Mesage here"
    .Recipients = Worksheets("Sheet2").Range("A1").Text '' I changed to sheet2 for address
    .ReturnWhenDone = False
    ActiveWorkbook.Route
    End With
    ActiveWorkbook.Saved = True
    ActiveWindow.Close
    End Sub

    HTH

    Charles

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1