Option Explicit
Private Sub userform_activate()
Dim i As Integer
Dim cb
For i = 1 To 5
Set cb = Controls("cboReason" & i)
cb.AddItem "Apple"
cb.AddItem "Egg"
cb.AddItem "Bread"
cb.AddItem "Cheese"
cb.AddItem "Milk"
Next
End Sub
Private Sub GenerateEmail_Click()
'CLEAN UP
Unload RARequest
'CREATE VARIABLES
Dim mai As MailItem
Dim Reason(1 To 5) As String
Dim i As Integer
Dim strText, RequestNotes As String
Dim CustNum, CustName, ContNum, ContName As String
Dim OrderNum, Reason1, Reason2, Reason3, Reason4, Reason5 As String
'POPULATE VARIABLES
CustNum = txtCustNum.Value
CustName = StrConv(txtCustName.Value, vbUpperCase)
ContNum = txtContNum.Value
ContName = StrConv(txtContName.Value, vbUpperCase)
RequestNotes = txtNotes.Value
OrderNum = txtOrderNum.Value
Reason(1) = cboReason1.Value
Reason(2) = cboReason2.Value
Reason(3) = cboReason3.Value
Reason(4) = cboReason4.Value
Reason(5) = cboReason5.Value
'COMPILE EMAIL BODY
strText = "<b><u>R/A REQUEST</b></u>"
strText = strText & "<br><br>"
strText = strText & "<b><u>CUSTOMER INFORMATION</b></u>"
strText = strText & "<br><br>"
strText = strText & "<b>Customer: </b>" & ContNum & " | " & ContName
strText = strText & "<br>"
strText = strText & "<b>Contact: </b>" & ContNum & " | " & ContName
strText = strText & "<br><br>"
strText = strText & "<b><u>ORDER INFORMATION</b></u>"
strText = strText & "<br><br>"
strText = strText & "<b>Order #: </b>" & OrderNum
strText = strText & "<br><br>"
For i = 1 To 5
If Reason(i) <> "" Then 'or <> "" Then
strText = strText & "<b>Reason " & i & "</b>" & " - " & Reason(i)
strText = strText & "<br>"
End If
Next i
strText = strText & "<br>"
strText = strText & "<b><u>ADDITIONAL INFORMATION</b></u>"
strText = strText & "<br><br>"
strText = strText & RequestNotes
strText = strText & "<br><br>"
'EMAIL OUTPUT
Set mai = Application.CreateItem(olMailItem)
With mai
.To = "geekamo@me.com"
.CC = "geekamo@me.com"
.Subject = "R/A (RQ) | " & CustNum & " - " & CustName & " | " & ContNum & " - " & ContName
.HTMLBody = "<p style='font-family:calibri'>" & strText & "</p>"
.Display
End With
End Sub
ASKER
ASKER
ASKER
Private Sub userform_activate()
Dim i As Integer, x As Integer
Dim cb, cbItem, cbItems As String
cbItems = "Apple Egg Bread Cheese Milk"
cbItem = Split(cbItems)
For i = 1 To 5
Set cb = Controls("cboReason" & i)
For x = LBound(cbItem) To UBound(cbItem)
cb.AddItem cbItem(x)
Next x
Next
End Sub
Visual Basic is Microsoft’s event-driven programming language and integrated development environment (IDE) for its Component Object Model (COM) programming model. It is relatively easy to learn and use because of its graphical development features and BASIC heritage. It has been replaced with VB.NET, and is very similar to VBA (Visual Basic for Applications), the programming language for the Microsoft Office product line.
TRUSTED BY
Open in new window
The line mai.display can easily be replaced by your assignment text and then sent instead of displayed.
Chris