Sendmail as long as all proper fields are filled out

sb003848

Board Regular
Joined
Sep 17, 2009
Messages
66
I'm trying to create a macro then when launched, it will look in the following cells and if one or more is not filled out, then the macro would stop giving an error message "Please fill all fields before submiting your request."!!!

Cells needing to be filled out are:
C6 - C7 - C8 - C9 - H6 - H7 - H8 - H9 - D14 - F20 - F21 - E27 - E28 - E29 - E30 - E31 - E32 - E33 - E34 - E35 - E36 - H27 - H28 - H29 - H30 - H31 - H32 - H33 - H34 - H35 - H36 -A41

If all the cells are filled out, then the entire workbook would be sent to:

TO: Info found in cell C9
CC: email1@email1.com; email2@email2.com
Subject: Reservation of kiosk

Thanks in advance for your assistance!
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi, something along these lines, adjust as needed

Code:
Dim OutApp As Object
    Dim OutMail As Object
    Dim strbody As String
    Dim user As Variant
    Dim users as string
 
with thisworkbook.sheets("Sheet1")
if .range("C6:C9").value = "" then
msgbox ("Error")
exit sub 
elseif .range("H6:H9").value = "" then
msgbox ("Error")
exit sub
elseif .range("D14").value = "" then
msgbox ("Error")
exit sub
elseif .range("F20:F21").value = "" then
msgbox ("Error")
exit sub
elseif .range("E27:E36").value = "" then
msgbox ("Error")
exit sub
elseif .range("H27:H36").value = "" then
msgbox ("Error")
exit sub
elseif .range("A41").value = "" then
msgbox ("Error")
exit sub
end with
else
 
 
        user = "[EMAIL="email1@email1.com"]email1@email1.com[/EMAIL];" & "[EMAIL="email2@email2.com"]email2@email2.com[/EMAIL];"
        users = thisworkbook.sheets("Sheet1").range("C9").value
 
        Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    strbody = 'whatever the body is
    On Error Resume Next
    With OutMail
        .To = users
        .CC = user
        .BCC = ""
        .Subject = "Enter subject"
        .body = strbody
        'You can add a file like this
        '.Attachments.Add ("C:\test.txt")
        .Send   'or use .Display
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    Set OutApp = Nothing
   end if
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,589
Messages
6,179,744
Members
452,940
Latest member
rootytrip

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