Hi.
I am learning VBA, and are working on a project that I can use for my work.
For reference - We work in a program based on IBM Reflection Software, so some commands will be from the Reflection for IBM 14.1 Object Library.
My question here though focuses on the Outlook part of the code.
I would like to create a macro that runs through x-amount of orders, writing specified info to an email from each order.
Below is the code I have written that does above for 1 order.
Is it possible to make a loop that runs the code, adds the text from the variables to the email, and goes through the loop again, using the same variables.
Again the focus here is on writing to the email.
Sub MailLoading1()
Dim CollF1 As Variant
Dim CollF2 As Variant
Dim CollF3 As Variant
Dim CollF4 As Variant
Dim txt As Variant
Dim OutlookApp As Outlook.Application
Dim OutlookMail As Outlook.MailItem
With Session
CollF1 = .GetDisplayText(6, 16, 30)
CollF2 = .GetDisplayText(6, 51, 30)
CollF3 = .GetDisplayText(7, 16, 30)
CollF4 = .GetDisplayText(7, 51, 30)
End With
Set OutlookApp = New Outlook.Application
Set OutlookMail = OutlookApp.CreateItem(olMailItem)
With OutlookMail
.BodyFormat = olFormatHTML
.HTMLBody = CollF1 & "<br>" & CollF2 & "<br>" & CollF3 & "<br>" & CollF4
.Display
End With
Set OutlookApp = Nothing
Set OutlookMail = Nothing
End Sub