Saturday, 17 January 2015

VBA sending email using outlook

Sub Sheet2_Button1_Click()

Dim strName As String

Dim strName1 As String

Dim strName2 As String

Dim strName9 As String

    strName = Range("I3").Value
          strName1 = Range("I5").Value
          strName2 = Range("I7").Value
          strName9 = Range("I9").Value
    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 = strName
        .CC = strName1
        .BCC = ""
        .Subject = strName2
        .Body = strName9

    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing

End Sub

No comments:

Post a Comment