Solved

Send email from Excel via dialog box

Posted on 2014-09-25
1
153 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 25

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
zeroMAx challenge 20 76
java constructor error 8 87
scoresClump  challenge 31 108
python sqlite question 11 43
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
A short article about problems I had with the new location API and permissions in Marshmallow
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

705 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now