Consulting

Results 1 to 2 of 2

Thread: Solved: Auto attach Worksheet to new outlook email

  1. #1

    Question Solved: Auto attach Worksheet to new outlook email

    Hi,

    What can I add to the following bit of my code to try and get it to attach the new workbook to an email?

    [vba]Sub EmailLineManager()
    Dim sSheetName As String
    Dim FileName As Variant


    On Error Resume Next
    sSheetName = Application.VLookup(Range("K12").Value, Range("F119:G127"), 2, False)
    On Error GoTo 0

    If sSheetName <> "" Then

    FileName = Range("E6").Value
    FileName = Mid(FileName, InStr(FileName, " ") + 1) & " " & _
    Left(FileName, InStr(FileName, " ") - 1) & _
    ", CONTRACT, " & Format(Range("K8").Value, "dd.mm.yy") & ".xls"
    FileName = Application.GetSaveAsFilename(FileName, "Microsoft Excel Files (*.xls), *.xls")
    If FileName <> False Then

    Worksheets(sSheetName).Copy
    ActiveWorkbook.SaveAs FileName

    End If
    Else
    MsgBox "You have not selected a Contract Type", vbOKOnly + vbInformation, "Information"
    End If



    End Sub
    [/vba]

    Here it currerntly just auto populates the Save As box for the user, using data from the worksheet......ideally I want it to attach itself to a new outlook email message and the filename to be automatically created using the code I already have.

    Thanks if you can help!!

  2. #2
    Knowledge Base Approver VBAX Wizard p45cal's Avatar
    Joined
    Oct 2005
    Location
    Surrey UK
    Posts
    5,876
    check out the likes of
    ActiveWorkbook.SendMail

    If this doesn't suit there are other ways which can use more of your current Outlook settings.
    p45cal
    Everyone: If I've helped and you can't be bothered to acknowledge it, I can't be bothered to look at further posts from you.

Posting Permissions

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