June 11, 2020
Greetings all,
i am planning to make an automated sheet that send an email once a f2, f3 , f4 ..... cell reaches certain value.
I would like to include the information in cell A2, A3, A4 AND B1, B2, B3... in the email body
The plan is to have an email for each row reaching that vlaue ..
tried this but its showing me only one email and i coulfnt add the inormation in that row.
Dim xRg As Range
'Update by Extendoffice 2018/3/7
Private Sub Worksheet_Change(ByVal Target As Range)
On Error Resume Next
If Target.Cells.Count > 1 Then Exit Sub
Set xRg = Intersect(Range("f2:f10000"), Target)
If xRg Is Nothing Then Exit Sub
If IsNumeric(Target.Value) And Target.Value > 180 Then
Call Mail_small_Text_Outlook
End If
End Sub
Sub Mail_small_Text_Outlook()
Dim xOutApp As Object
Dim xOutMail As Object
Dim xMailBody As String
Set xOutApp = CreateObject("Outlook.Application")
Set xOutMail = xOutApp.CreateItem(0)
xMailBody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2"
On Error Resume Next
With xOutMail
.To = "mohd.althobaiti@outlook.com"
.CC = ""
.BCC = ""
.Subject = "6 months"
.Body = xMailBody
.Display 'or use .Send
End With
On Error GoTo 0
Set xOutMail = Nothing
Set xOutApp = Nothing
End Sub
Can any one help please.
Thank you all.
October 5, 2010
Hi Mido,
Welcome to the forum. On the face of it this looks like something I can help with but I'm missing some important information.
Please always attach your workbook with data when posting a question otherwise I'm guessing as to what data you are working with.
Other info I need:
1. send an email once a f2, f3 , f4 ..... cell reaches certain value. : what values?
2. include the information in cell A2, A3, A4 AND B1, B2, B3 : how so? In what format? What's in these cells? Text? Numbers? This is where seeing the workbook helps me.
Thanks
Phil
June 11, 2020
Greetings,
Thank you for your reply and apologies for missing this information.
My objective is send an automated email once the employee reaches 6 months on acting assignment.
Technically, once the value in column E reach 180, and automated email should be sent out to the email on column F, stating the corresponding employee name and badge number in column A and B in the email Body.
Thank you for you support.
I have attached the file without the VBA due to size restriction.
October 5, 2010
Hi Mido,
The attached file will send emails based on the criteria you stated.
There needs to be some way for the code to be started so it is placed inside a worksheet change event. Each time the sheet is changed the code will run to check if it needs to send any emails.
You need to record that an email has been sent, so the code knows not to send another email. The code enters the date an email was sent into a new column, 'Email Sent' for this purpose.
As it is the code will only display the email for you, it won't send it. This is just for testing purposes so you can check it works as you want.
When you are happy you just need to change the value of the DisplayEmail variable from True to false. You'll find this in the code towards the top.
Regards
Phil
June 11, 2020
This is working just fine dear Philip.
Yet, these details change frequently, my plan is to update the data in column 1 , 2 and 3 bi weekly or monthly.
With every change the emails will pop again and the record for the email sent column will be changed.
Honestly, not sure how can we make this happen with proper control.
Truly appreciate your support.
October 5, 2010
Hi Mido,
The code will send an email when the value in Col E is >= 180.
When an email is sent the code will enter the date the email was sent into Col G.
If there is a date in Col G then another email will not be sent for the same person.
So, whatever changes you make - like adding new people to the table - won't result in multiple emails being sent for the same person.
You can confirm this by running the code once to see the emails that are created (sent) - a date is entered in Col G.
If you run the code again, emails are not created for those people who have already had an email sent.
Regards
Phil
June 11, 2020
Hi dear Philip,
Completely understand, however, the process that will take place is basically generating the Acting placement report from SAP, copying name badge and date assigned and paste them all in this automated sheet. What i am trying to say is that this is not gonna be a manual input and adding rows.
Thank you and appreciated.
October 5, 2010
So if you are overwriting the data every time you take a report from SAP, there is no way to know what emails have been sent, with the current code.
You could use Power Query to merge the current table showing emails sent, and the new data from SAP?
Or you could have a workbook that has a sheet where sent emails are recorded. The SAP report is pasted/imported into a sheet in this workbook and the data from both sheets compared?
Phil
October 5, 2010
Hi Mido,
I've created a new sheet and a table on that sheet to keep track of what emails have been sent.
The records will show the person's name, badge number and the date the email was sent.
When you place the new data from SAP into Sheet1, the code checks through all the rows looking for the badge number and checking if that badge number exists n the table on the 2nd sheet. If the badge number exists n the table, then an email has already bee sent for that person.
Regards
Phil
1 Guest(s)