Help with Excel to Outlook Macro

RumMajor

New Member
Joined
Jul 16, 2012
Messages
11
OK, I'm pretty new to VBA but I have been able to piece this code together and now I'm stuck. What I would like is a code that will open a new email in outlook, insert cell values in to the buy and display for me to double check.

I have everything figured out excel two things.
1) I would like it to skip over lines if there is no value in column F (Textbook1,2,3,etc...) to make the email more concise.
2) I would like it to add the senders default outlook signature.

Like I said I am pretty new and I have gotten it to do ALMOST everything I want.

I know I could just delete the empty lines and add the signature myself but I figured if I could, I might as well try and automate it all.

Thank you for any help you can offer.

Sub SendReceiptRequest()

Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

'Use Syntax
StudentName = Range("D17").Value
Course1 = Range("D4").Value
Course2 = Range("D5").Value
Course3 = Range("D6").Value
Course4 = Range("D7").Value
Course5 = Range("D8").Value
Course6 = Range("D9").Value
Course7 = Range("D10").Value
Course8 = Range("D11").Value
Course9 = Range("D12").Value
Course10 = Range("D13").Value
Edition1 = Range("E4").Value
Edition2 = Range("E5").Value
Edition3 = Range("E6").Value
Edition4 = Range("E7").Value
Edition5 = Range("E8").Value
Edition6 = Range("E9").Value
Edition7 = Range("E10").Value
Edition8 = Range("E11").Value
Edition9 = Range("E12").Value
Edition10 = Range("E13").Value
Textbook1 = Range("F4").Value
Textbook2 = Range("F5").Value
Textbook3 = Range("F6").Value
Textbook4 = Range("F7").Value
Textbook5 = Range("F8").Value
Textbook6 = Range("F9").Value
Textbook7 = Range("F10").Value
Textbook8 = Range("F11").Value
Textbook9 = Range("F12").Value
Textbook10 = Range("F13").Value
ISBN1 = Range("G4").Value
ISBN2 = Range("G5").Value
ISBN3 = Range("G6").Value
ISBN4 = Range("G7").Value
ISBN5 = Range("G8").Value
ISBN6 = Range("G9").Value
ISBN7 = Range("G10").Value
ISBN8 = Range("G11").Value
ISBN9 = Range("G12").Value
ISBN10 = Range("G13").Value
Author1 = Range("H4").Value
Author2 = Range("H5").Value
Author3 = Range("H6").Value
Author4 = Range("H7").Value
Author5 = Range("H8").Value
Author6 = Range("H9").Value
Author7 = Range("H10").Value
Author8 = Range("H11").Value
Author9 = Range("H12").Value
Author10 = Range("H13").Value
Format1 = Range("J4").Value
Format2 = Range("J5").Value
Format3 = Range("J6").Value
Format4 = Range("J7").Value
Format5 = Range("J8").Value
Format6 = Range("J9").Value
Format7 = Range("J10").Value
Format8 = Range("J11").Value
Format9 = Range("J12").Value
Format10 = Range("J13").Value
Dash1 = Range("L4").Value
Dash2 = Range("L5").Value
Dash3 = Range("L6").Value
Dash4 = Range("L7").Value
Dash5 = Range("L8").Value
Dash6 = Range("L9").Value
Dash7 = Range("L10").Value
Dash8 = Range("L11").Value
Dash9 = Range("L12").Value
Dash10 = Range("L13").Value

strbody = "Hi there " & StudentName & ", " & vbNewLine & vbNewLine & _
"You have received this email to inform you that the following textbooks are ready to be picked up at disability support services. " & vbNewLine & vbNewLine & _
Textbook1 & " " & Dash1 & " " & Course1 & vbNewLine & _
Textbook2 & " " & Dash2 & " " & Course2 & vbNewLine & _
Textbook3 & " " & Dash3 & " " & Course3 & vbNewLine & _
Textbook4 & " " & Dash4 & " " & Course4 & vbNewLine & _
Textbook5 & " " & Dash5 & " " & Course5 & vbNewLine & _
Textbook6 & " " & Dash6 & " " & Course6 & vbNewLine & _
Textbook7 & " " & Dash7 & " " & Course7 & vbNewLine & _
Textbook8 & " " & Dash8 & " " & Course8 & vbNewLine & _
Textbook9 & " " & Dash9 & " " & Course9 & vbNewLine & _
Textbook10 & " " & Dash10 & " " & Course10 & vbNewLine & vbNewLine & _
"However, I have not received a copy of your receipt as proof of purchase to release your textbooks. At your convenience, please stop by disability support, with a copy of your receipt so we can make a copy and your textbooks can be given to you." & vbNewLine & vbNewLine & _
"If you have not yet purchased your books or have misplaced your receipt you can find help at the OTC bookstore where you may purchase your books or request a copy of your receipt." & vbNewLine & vbNewLine & _
"If you have any other questions regarding this email or your textbooks please feel free to contact me." & vbNewLine & vbNewLine & _
"See you soon!" & vbNewLine & vbNewLine & vbc & Signature

On Error Resume Next
Signature = OutMail.Body
With OutMail
.To = Range("I2").Value
.CC = ""
.BCC = ""
.Subject = "Receipt Request"
.Body = strbody & vbNewLine & vbNewLine & Signature
.Display
End With

On Error GoTo 0


Set OutMail = Nothing
Set OutApp = Nothing


End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,214,983
Messages
6,122,595
Members
449,089
Latest member
Motoracer88

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