Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel Email macro

Status
Not open for further replies.

JohnOB

Technical User
Oct 5, 2006
253
GB
Hi All

Hope someone can help me with the below I have been looking for examples of code to try and help but with no luck.

I want to have a button in a spreadsheet which when clicked will open a new email.

I do not want the file attached to the email, however I would like the contents of some of the cells to appear as part of the subject and body, I would also like the full file path to appear as part of the body.

The idea is that when someone completes a part of the spreadsheet they hit this button and it creates an email to let someone know the spreadsheet has been updated and the location of it. The person who gets the email will always be the same person.

All examples I can find show me how to attach the sheet or workbook which I don't want to do, or they use Outlook which we do not use (Lotus Notes) so need a generic new mail command and not any sort of outlook object.

Any advice appreciated.

Thanks

John

"Stupid isn't not knowing the answer, it's not asking the question
 


Hi,

What code do you have so far? Where are you stuck?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
I found this code on the net (some where)

Code:
Sub Send_Email_Using_VBA()

    Dim strSubject, strSendFrom, strBody, strFName As String
    Dim strSendTo As String
    Dim strLinkPath, strMatlFile, strFileName As String
    strMatlFile = Sheets("Lookup").Range("D2") & " Materials Expense.xlsm"
    strFilePath = Sheets("Lookup").Range("D4")
    Dim otlMailObject, otlMailSingle As Variant
    strSubject = "Subject"
    strSend_From = "From"
    strSendTo = "To"
    strBody = "Body"
    strFName = "path with file name"
    Workbooks(strMatlFile).Close
    On Error GoTo debugs
    Set otlMailObject = CreateObject("Outlook.Application")
    Set otlMailSingle = otlMailObject.CreateItem(0)
    With otlMailSingle
        .Subject = strSubject
        .To = strSendTo
        .Body = strBody
        .Attachments.Add strFName
        .send
    End With
debugs:
    If Err.Description <> "" Then MsgBox Err.Description
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top