Email Information from Sheet & Loop

XfortunaX

New Member
Joined
Aug 28, 2014
Messages
28
I need help! :eeek:

I am looking to create and send an email from information stored on a sheet sent from my my (2) Outlook address.

Issues:
The loop I have tried errors out on the second person.
The length of rows changes every week.
The outlook item (2) still pulls address (1)

The details:
Column A: Employee Name (irrelevant for this)
Column B: File Name (Irrelevant for this)
Column C: Employee Email
Column D: File Path to attachment



Sub Mail_workbook_Outlook_1()


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

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


strbody = "Good afternoon," & vbNewLine & vbNewLine & _
"Attached is your portion of the American Express bill - closing date 04.28.2015." & vbNewLine & vbNewLine & _
"Within the attached excel document, you will find 3 tabs:" & vbNewLine & vbNewLine & _
"Tab 1 (Your Name): All charges on your American Express for the period. Please review for accuracy and fraudulent activity. If there appears to be fraudulent activity, please contact finance immediately. On this sheet, you will complete the code column by filling in a number found on the Chart of Accounts (Chart of Accounts located on the Amex Instructions page or Tab 2) for the charge, write who was present, and write what the purpose was. Once complete, please write your name and date in the space provided." & vbNewLine & vbNewLine & _
"Tab 2 (AMEX Instructions): This sheet includes brief instructions on the overall process, the Chart of Accounts (used for coding each charge), and examples of what charges would fall under which code numbers." & vbNewLine & vbNewLine & _
"Tab 3 (AMEX Receipt Return): Please print and sign this page and return with your receipts to your manager." & vbNewLine & vbNewLine & _
" If you received this electronically, please return this to your manager electronically. Please print the Receipt Return page, sign, and send in with your receipts to your manager." & vbNewLine & _
" If you are receiving a hardcopy of your American Express bill, please return to your manager signed and with receipts." & vbNewLine & _
" If there appears to be fraudulent activity, please contact finance immediately." & vbNewLine & vbNewLine & _
"If you have any questions, please do not hesitate to ask John or Eileen by phone or sending an email to EiFinance@horizonsalescorp.com" & vbNewLine & vbNewLine & _
"Thank you!" & vbNewLine & vbNewLine & _
"Jr" & vbNewLine & vbNewLine & _
"Phone: 949 218 XXXX" & vbNewLine & _
"Email: EiFinance@salecorp.com"


On Error Resume Next
x = 2
Do While Cells(x, 1)

With OutMail
.To = Cells(x, 3)
.CC = ""
.BCC = ""
.Subject = "Platinum_04.28.2015"
.Body = strbody
.Attachments.Add Cells(x, 4)
'You can add other files also like this .Attachments.Add ("C:\test.txt")
'Change Item(1)to the account number that you want to use HS. is (1) and Finance. is (2)
.SendUsingAccount = OutApp.Session.Accounts.Item(2)
.Display 'or use .Send


End With
On Error GoTo 0


Set OutMail = Nothing
Set OutApp = Nothing


x = x + 1
Loop

End Sub


Thank you for any help that can be provided!

- JT
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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