Hi thread,
Try to set up VBA to help me automate my remittance advice sending..
I want to loop through the rows in the table. But I am so new to the VBA, I need some help.
Here is the code for my VBA.
Sub Mail()
Dim OutlookApp As Object
Dim Mess As Object, Recip
Dim Body As String
Recip = [A2].Value
Set OutlookApp = CreateObject("Outlook.Application")
Set Mess = OutlookApp.CreateItem(olMailItem)
With Mess
.Subject = [D2].Value & " " & [C2].Value & " " & "Remittance Advice"
Dim mymsg As String
mymsg = "Hi there" & vbCrLf & vbCrLf
mymsg = mymsg & "Please find the remittance advice below." & vbCrLf & vbCrLf
mymsg = mymsg & "Vendor Name:" & " " & [D2].Value & vbCrLf
mymsg = mymsg & "Invoice No.:" & " " & [E2].Value & vbCrLf
mymsg = mymsg & "Invoice Date:" & " " & [F2].Value & vbCrLf & vbCrLf
mymsg = mymsg & "Payment Date:" & " " & [C2].Value & vbCrLf
mymsg = mymsg & "Amount paid:" & " " & "$" & " " & [G2].Value & vbCrLf & vbCrLf
mymsg = mymsg & "Regards"
.Body = mymsg
.To = Recip
.Display
.Send
End With
End Sub
Is there any way to modify it to get it loop through rows?
Eg.
C2 abc@gmail.com
C3 zxy@gmail.com
loop through very end.
I also have cell reference for body contents. I need to get those contents to loop through as different row has different content.
Thanks in advance for your precious time.
AZ
Try to set up VBA to help me automate my remittance advice sending..
I want to loop through the rows in the table. But I am so new to the VBA, I need some help.
Here is the code for my VBA.
Sub Mail()
Dim OutlookApp As Object
Dim Mess As Object, Recip
Dim Body As String
Recip = [A2].Value
Set OutlookApp = CreateObject("Outlook.Application")
Set Mess = OutlookApp.CreateItem(olMailItem)
With Mess
.Subject = [D2].Value & " " & [C2].Value & " " & "Remittance Advice"
Dim mymsg As String
mymsg = "Hi there" & vbCrLf & vbCrLf
mymsg = mymsg & "Please find the remittance advice below." & vbCrLf & vbCrLf
mymsg = mymsg & "Vendor Name:" & " " & [D2].Value & vbCrLf
mymsg = mymsg & "Invoice No.:" & " " & [E2].Value & vbCrLf
mymsg = mymsg & "Invoice Date:" & " " & [F2].Value & vbCrLf & vbCrLf
mymsg = mymsg & "Payment Date:" & " " & [C2].Value & vbCrLf
mymsg = mymsg & "Amount paid:" & " " & "$" & " " & [G2].Value & vbCrLf & vbCrLf
mymsg = mymsg & "Regards"
.Body = mymsg
.To = Recip
.Display
.Send
End With
End Sub
Is there any way to modify it to get it loop through rows?
Eg.
C2 abc@gmail.com
C3 zxy@gmail.com
loop through very end.
I also have cell reference for body contents. I need to get those contents to loop through as different row has different content.
Thanks in advance for your precious time.
AZ