Patriot2879
Well-known Member
- Joined
- Feb 1, 2018
- Messages
- 1,259
- Office Version
- 2010
- Platform
- Windows
Hi, I have created VBA code in Excel that takes the contents of a recordset and places the data (Date and Area) in the body of an email message. My code looks like this:
This code all works great. The problem is that I want to output additional fields ( Date)and Area), and I want the data to appear in a table so that the data is formatted nicely. I have tried separating the fields with tabs, but I have no way of knowing the length of the data in each field, so the data does not line up correctly.
Is this possible at all to put a table around the Date and Area textbox? Any help would be much appreciated!
I have included the 2 lines where i want a table around and the full coding.
This code all works great. The problem is that I want to output additional fields ( Date)and Area), and I want the data to appear in a table so that the data is formatted nicely. I have tried separating the fields with tabs, but I have no way of knowing the length of the data in each field, so the data does not line up correctly.
Is this possible at all to put a table around the Date and Area textbox? Any help would be much appreciated!
I have included the 2 lines where i want a table around and the full coding.
Code:
"Date:" & vbTab & Me.TextBox18.Value & vbTab & Me.TextBox19.Value & vbTab & Me.TextBox21.Value & vbCrLf & _
"Area:" & vbTab & Me.TextBox9.Value & vbTab & vbTab & Me.TextBox20.Value & vbTab & vbTab & Me.TextBox22.Value & vbCrLf & _
Code:
Private Sub CommandButton1_Click()
Dim aOutlook As Object
Dim aEmail As Object
Dim rngeAddresses As Range, rngeCell As Range, strRecipients As String
Set aOutlook = CreateObject("Outlook.Application")
Set aEmail = aOutlook.CreateItem(0)
aEmail.Body = "Hi There," & Chr(10) & vbCrLf & _
"" & Me.TextBox33.Value & Chr(10) & _
"Date:" & vbTab & Me.TextBox18.Value & vbTab & Me.TextBox19.Value & vbTab & Me.TextBox21.Value & vbCrLf & _
"Area:" & vbTab & Me.TextBox9.Value & vbTab & vbTab & Me.TextBox20.Value & vbTab & vbTab & Me.TextBox22.Value & vbCrLf & _
"" & Me.TextBox17.Value & Chr(10) & vbCrLf & _
"Many thanks " & Chr(10)
aEmail.Recipients.Add "test.test@test.com; test.test@test.com"
aEmail.CC = ""
aEmail.BCC = ""
aEmail.Subject = "Weekly " & Range("D2").Value
aEmail.Display