VBA adding Signature to Outlook Email sent from Excel on certain date

BLCannon

New Member
Joined
Mar 28, 2008
Messages
45
I have this code below that when a date is entered an email is sent.

Question 1: If the date is a future date will the email send on that date when the excel file is opened. Say date is in Excel for 7/5/2018. Today's date is 7/2 - will the email send when I open the spreadsheet 7/5?

Question 2: Several people will use the excel spreadsheet. How best would it be for their signature to be added to the email along with title and phone contact and formatted for Outlook?

Question 3. Is there a better way to send email notifications with Excel on a specific date?

Sub email()
Dim r As Range
Dim cell As Range
Set r = Range("A1:S20")
For Each cell In r
If cell.Value = Date Then
Dim Email_Subject, Email_Send_From, Email_Send_To, _
Email_Cc, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant
Email_Subject = Cells(cell.Row, "C").Value
Email_Send_From = "xxx@xx.com
Email_Send_To = "xxx@xx.com
Email_Cc = ""
Email_Bcc = ""
Email_Body = "Hi " & Cells(cell.Row, "c").Value _
& vbNewLine & vbNewLine & _
Cells(cell.Row, "D").Value & _
" has been submited"
On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body
.send
End With
End If
Next

Exit Sub
debugs:
If Err.Description <> "" Then MsgBox Err.Description
End Sub
 
Last edited:

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I have this code below that when a date is entered an email is sent.

Question 1: If the date is a future date will the email send on that date when the excel file is opened. Say date is in Excel for 7/5/2018. Today's date is 7/2 - will the email send when I open the spreadsheet 7/5?

Question 2: Several people will use the excel spreadsheet. How best would it be for their signature to be added to the email along with title and phone contact and formatted for Outlook?

Question 3. Is there a better way to send email notifications with Excel on a specific date?

Sub email()
Dim r As Range
Dim cell As Range
Set r = Range("A1:S20")
For Each cell In r
If cell.Value = Date Then
Dim Email_Subject, Email_Send_From, Email_Send_To, _
Email_Cc, Email_Bcc, Email_Body As String
Dim Mail_Object, Mail_Single As Variant
Email_Subject = Cells(cell.Row, "C").Value
Email_Send_From = "xxx@xx.com
Email_Send_To = "xxx@xx.com
Email_Cc = ""
Email_Bcc = ""
Email_Body = "Hi " & Cells(cell.Row, "c").Value _
& vbNewLine & vbNewLine & _
Cells(cell.Row, "D").Value & _
" has been submited"
On Error GoTo debugs
Set Mail_Object = CreateObject("Outlook.Application")
Set Mail_Single = Mail_Object.CreateItem(0)
With Mail_Single
.Subject = Email_Subject
.To = Email_Send_To
.cc = Email_Cc
.BCC = Email_Bcc
.Body = Email_Body
.send
End With
End If
Next

Exit Sub
debugs:
If Err.Description <> "" Then MsgBox Err.Description
End Sub



I found this code to add Signature but not sure how to add t
'Dim OApp As Object, OMail As Object, Signature As String
'Set OApp = CreateObject("Outlook.Application")
Set OMail = OApp.CreateItem(0)
With OMail
.Display
End With
Signature = OMail.body
With OMail
'.To = "someone@somedomain.com"
'.Subject = "Type your email subject here"
'.Attachments.Add
.body = "Add body text here" & vbNewLine & Signature
'.Send
End With
Set OMail = Nothing
Set OApp = Nothingo my code
 
Upvote 0
I found this code that works for signature - I just need to combine cell references.

For my question as to whether the email would be sent on date opened if that date is referenced in a cell probably would be an OnOpen event??


Sub Mail_Outlook_With_Signature_Html_1()
' Working in Office 2000-2016
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "<H3><B>Dear Customer Ron de Bruin</B></H3>" & _
"Please visit this website to download the new version.<br>" & _
"Let me know if you have problems.<br>" & _
"<A HREF=""http://www.rondebruin.nl/tips.htm"">Ron's Excel Page</A>" & _
"<br><br><B>Thank you</B>"
On Error Resume Next
With OutMail
.Display
.To = "user@doman.com"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.HTMLBody = strbody & "<br>" & .HTMLBody
.Send
End With

On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,954
Messages
6,175,601
Members
452,658
Latest member
GStorm

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