VBA Code to send email to address in cell A1

Malcolm torishi

Board Regular
Joined
Apr 26, 2013
Messages
219
Does any one know how to send an email from a button on a spread sheet to an email address that is saved on the same spread sheet under cell A1
if any one could help please
thank you
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
good Day
Code:
Public Sub SendAttach()
'Attach1 = ThisWorkbook.Path & "\" & "" & ".xlsx" ' if excel
'Attach2 = ThisWorkbook.Path & "\" & "" & ".PNG" ' if Picture or ".GIF"
'Attach3 = ThisWorkbook.Path & "\" & "" & ".Docx" ' if word doc
    On Error Resume Next
    Dim OutApp As Variant
    Dim OutMail As Variant
    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
    On Error Resume Next
    With OutMail
        .To = Range("A1") ' or like"[EMAIL="someone@xxxx.com"]someone@xxxx.com[/EMAIL]"
        .CC = "" ' or like"[EMAIL="someone@xxxx.com"]someone@xxxx.com[/EMAIL]"
        .Subject = "MySubject"
        On Error Resume Next
        '.Attachments.Add Attach1
        '.Attachments.Add Attach2
        '.Attachments.Add Attach3
        On Error GoTo 0
         .Save
        .Display
        '.send '<<<<< if you wand to send dirict remove "'" to be .send
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
    On Error Resume Next
   ' Kill FilePath
'Kill Attach1
'Kill Attach2
'Kill Attach13
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top