Send Gmail if J3 = L

Rubber Beaked Woodpecker

Board Regular
Joined
Aug 30, 2015
Messages
203
Office Version
  1. 2021
Hi is it possible for excel to send an email via Gmail if a cell contains the correct data?

I have a workbook where if sheet9 J3 = L I would like this to trigger an email via Gmail.

Many thanks

RBW
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Hi there

Yes, it is possible to send an email via Gmail from Excel based on a condition in a cell.

Here's an example VBA code that you can modify to fit your specific needs:

VBA Code:
Sub OpenEmail()
    Dim EmailSubject As String
    Dim SendTo As String
    Dim EmailBody As String
    Dim Mail_Object As Object
    Dim Email_Send_To As String
    Dim Email_Cc As String
    Dim Email_Bcc As String
    Dim Email_Attachment_Path As String
    Dim myApp As Object
    Dim myMail As Object
    
    'Check if cell J3 in sheet9 equals "L"
    If Sheets("sheet9").Range("J3").Value = "L" Then
        
        'Email subject
        EmailSubject = "Subject of your email"
        
        'Email body
        EmailBody = "This is the body of your email"
        
        'Recipient email address
        SendTo = "recipient@email.com"
        
        'Create email object
        Set myApp = CreateObject("Outlook.Application")
        Set myMail = myApp.CreateItem(0)
        
        'Set email properties
        With myMail
            .Subject = EmailSubject
            .To = SendTo
            .Body = EmailBody
        End With
        
        'Display email
        myMail.Display
        
        'Release email object from memory
        Set myMail = Nothing
        Set myApp = Nothing
        
    End If
    
End Sub



In this example code, if cell J3 in sheet9 equals "L", an email will be sent to the specified recipient with the specified subject and body. You will need to modify the values of the EmailSubject, SendTo, and EmailBody variables to match your specific needs.
 
Upvote 0
Hi there

Yes, it is possible to send an email via Gmail from Excel based on a condition in a cell.

Here's an example VBA code that you can modify to fit your specific needs:

VBA Code:
Sub OpenEmail()
    Dim EmailSubject As String
    Dim SendTo As String
    Dim EmailBody As String
    Dim Mail_Object As Object
    Dim Email_Send_To As String
    Dim Email_Cc As String
    Dim Email_Bcc As String
    Dim Email_Attachment_Path As String
    Dim myApp As Object
    Dim myMail As Object
   
    'Check if cell J3 in sheet9 equals "L"
    If Sheets("sheet9").Range("J3").Value = "L" Then
       
        'Email subject
        EmailSubject = "Subject of your email"
       
        'Email body
        EmailBody = "This is the body of your email"
       
        'Recipient email address
        SendTo = "recipient@email.com"
       
        'Create email object
        Set myApp = CreateObject("Outlook.Application")
        Set myMail = myApp.CreateItem(0)
       
        'Set email properties
        With myMail
            .Subject = EmailSubject
            .To = SendTo
            .Body = EmailBody
        End With
       
        'Display email
        myMail.Display
       
        'Release email object from memory
        Set myMail = Nothing
        Set myApp = Nothing
       
    End If
   
End Sub



In this example code, if cell J3 in sheet9 equals "L", an email will be sent to the specified recipient with the specified subject and body. You will need to modify the values of the EmailSubject, SendTo, and EmailBody variables to match your specific needs.
Thanks Jimmypop
 
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,918
Members
449,195
Latest member
Stevenciu

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