Macro to email student info from a row to email address within row

rich_d

New Member
Joined
Sep 2, 2013
Messages
1
Hello,

I have a student mark book in excel, and I want a macro which will to send the assignment/homework scores for each student to that student, in an email with a bit of other text in the body of the email.

To describe the spreadsheet clearly:

Column A = student no.
Column C = student name
Column D = student email
Column E - J = student info that doesn't need to be sent
Column K onwards = assignment/homework scores that should be send out

Row 1 = random info that doesn't need to be sent
Row 2 = assignment/homework titles, e.g. assignment 1, assignment 2, etc. - these also need to be included in the email, so the scores all make sense and aren't just a random list of numbers.
Row 3 onwards = student info, scores, etc.


The email should be something like:
Dear student name (student no.)

Below are your assignment grades so for for this course blah blah

Assignment 1: 74
Assignment 2: 45
Assignment 3: 0

Regards, Blah blah, your teacher.​


I've searched around a bit and found some codes that are somewhat close, but being a science teacher I'm so far out of my depth with this stuff!

The computing teachers and IT guys here don't really know how to do what I'm after. I really hope someone here can help. This will make what would otherwise be an awful task (copying scores for 100+ students, every week, each into a new email) so quick and easy!
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
try

Code:
Sub rich_d()
Dim OutApp As Object
Dim OutMail As Object
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")


For i = 3 To Range("A" & Rows.Count).End(xlUp).Row
Set OutMail = OutApp.CreateItem(0)
 strbody = "Dear " & Cells(i, "C") & vbNewLine _
            & vbNewLine _
            & "Below are your assignment grades so for for this course blah blah" & vbNewLine _
            & vbNewLine _
            & "Assignment 1: " & Cells(i, "K") & vbNewLine _
            & "Assignment 2: " & Cells(i, "L") & vbNewLine _
            & "Assignment 3: " & Cells(i, "M") & vbNewLine _
            & vbNewLine _
            & "Regards, Blah blah, your teacher."
            
 On Error Resume Next
  With OutMail
   .To = Cells(i, "D")
   .Subject = "assignment/homework scores"
   .Body = strbody
   .send
  End With
 On Error GoTo 0
Set OutMail = Nothing
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,243
Messages
6,170,971
Members
452,371
Latest member
Frana

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