How to send the automated gmail from excel sheet content

RAJASEKHAR84

New Member
Joined
Dec 11, 2018
Messages
1
HI,


I have the data in google Excel sheet.


How to send auto generated gmail from that excel cell contents


Need to send status report on daily basics


Eg:


To:Distro to be sent
Subject: Status report
Body Content:
All,
Please find the status report
Table format to be displayed from that excel sheet data


Thanks,
My Name.
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Code:
Sub SendEmailUsingGmail()

    On Error GoTo Err


    Dim NewMail As Object
    Dim mailConfig As Object
    Dim fields As Variant
    Dim msConfigURL As String


    Set NewMail = CreateObject("CDO.Message")
    Set mailConfig = CreateObject("CDO.Configuration")


    ' load all default configurations
    mailConfig.Load -1


    Set fields = mailConfig.fields


'Set All Email Properties


    With NewMail
        .Subject = "Test Mail from LearnExcelMacro.com"
        .From = "email@gmail.com"
        .To = "email2@gmail.com;email3@gmail.com"
        .CC = "email4@gmail.com"
        .BCC = ""
        .textbody = ""
    End With


    msConfigURL = "http://schemas.microsoft.com/cdo/configuration"


    With fields
        'Enable SSL Authentication
        .Item(msConfigURL & "/smtpusessl") = True


        'Make SMTP authentication Enabled=true (1)
        .Item(msConfigURL & "/smtpauthenticate") = 1


        'Set the SMTP server and port Details
        'To get these details you can get on Settings Page of your Gmail Account
        .Item(msConfigURL & "/smtpserver") = "smtp.gmail.com"
        .Item(msConfigURL & "/smtpserverport") = 465
        .Item(msConfigURL & "/sendusing") = 2


        'Set your credentials of your Gmail Account
        .Item(msConfigURL & "/sendusername") = "email@gmail.com"
        .Item(msConfigURL & "/sendpassword") = "********"


        'Update the configuration fields
        .Update


    End With
    NewMail.Configuration = mailConfig
    NewMail.Send
    MsgBox ("Mail has been Sent")


Exit_Err:


    Set NewMail = Nothing
    Set mailConfig = Nothing
    End


Err:
    Select Case Err.Number


    Case -2147220973  'Could be because of Internet Connection
        MsgBox " Could be no Internet Connection !!  -- " & Err.Description


    Case -2147220975  'Incorrect credentials User ID or password
        MsgBox "Incorrect Credentials !!  -- " & Err.Description


    Case Else   'Rest other errors
        MsgBox "Error occured while sending the email !!  -- " & Err.Description
    End Select


    Resume Exit_Err


End Sub

Source: http://learnexcelmacro.com/wp/2011/12/how-to-send-an-email-using-excel-macro-from-gmail-or-yahoo/
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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