Solved

Send email from Excel via dialog box

Posted on 2014-09-25
1
164 Views
Last Modified: 2014-10-02
The code below works in Excel 2010 to send an e-mail via Outlook 2010 when a dialog box in Excel is clicked. However, it is not working with Excel 2013 and Outlook 2013. Why?

Sub Engr_Notification()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
    Dim quote As String

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    Set quote = Range.ActiveCell()

    strbody = "A new quote is ready for pricing. See Quote #" & quote

    On Error Resume Next
    With OutMail
        .To = "test@123.com"
        .CC = ""
        .BCC = ""
        .Subject = "A new RFQ is ready for pricing"
        .Body = strbody
        .Send
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub
0
Comment
Question by:btgtech
1 Comment
 
LVL 26

Accepted Solution

by:
ProfessorJimJam earned 500 total points
ID: 40345577
check this one it works in 2013

Sub Mail_workbook_Outlook_1()
'Working in Excel 2000-2013
'This example send the last saved version of the Activeworkbook
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
    Dim OutApp As Object
    Dim OutMail As Object

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
        .to = "ron@debruin.nl"
        .CC = ""
        .BCC = ""
        .Subject = "This is the Subject line"
        .Body = "Hi there"
        .Attachments.Add ActiveWorkbook.FullName
        'You can add other files also like this
        '.Attachments.Add ("C:\test.txt")
        .Send   'or use .Display
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
End Sub

Open in new window


alternativelly there are other two codes also working

check it out.

http://www.rondebruin.nl/win/s1/outlook/amail1.htm
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an explanation of a simple data model to help parse a JSON feed
This is about my first experience with programming Arduino.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question