Sub SendOutlookInvoice()
Dim ws As Worksheet, sTo As String, sAmount As String, sDueDate As String, sSubject As String
Dim oOutlookApp As Object, oOutlookMail As Object
Set oOutlookApp = CreateObject("Outlook.Application")
oOutlookApp.Session.Logon
Cells(5, ActiveCell.Column).Select
Application.ScreenUpdating = False
Set ws = ActiveSheet
With ws
sTo = ActiveCell.Offset(52, 0).Value
sAmount = ActiveCell.Offset(11, 0).Value
sDueDate = ActiveCell.Value
sSubject = ActiveCell.Offset(-2, 0).Value
sContact = ActiveCell.Offset(51, 0).Value
sHosting = ActiveCell.Offset(53, 0).Value
End With
Set oOutlookMail = oOutlookApp.CreateItem(0)
On Error Resume Next
With oOutlookMail
.To = sTo
.CC = ""
.BCC = ""
.Subject = "Annual renewal of website www." & sSubject
.Body = "Dear " & sContact & vbCrLf & vbCrLf & "Your website www." & sSubject & " annual " & sHosting & " is due for renewal on " & sDueDate & "." & vbCrLf & vbCrLf & "Please find attached an invoice for $" & sAmount & " for one years renewal of these services." & vbCrLf & vbCrLf & "This email is automatically generated. Please feel free to contact us should you need help. If you consider this invoice is incorrect, or you have been wrongly sent this mail, please contact us." & vbCrLf & vbCrLf & "Croxford Technology" & vbCrLf & "68b Kennels Lane" & vbCrLf & "RD2, Wanaka" & vbCrLf & "New Zealand" & vbCrLf & "Ph +64 (0)3 443 4672" & vbCrLf & "Email: [email protected]" & vbCrLf & vbCrLf & "Regards," & vbCrLf & vbCrLf & "Will Croxford"
.Display
End With
On Error GoTo 0
Set oOutlookMail = Nothing
Set oOutlookApp = Nothing
Application.ScreenUpdating = True
End Sub
|