tommy1234
01-17-2009, 11:34 AM
Hello
i wrote a code which transfer data from excel to outlook email body.
i have to align the text to the right, but i don't know how.
Thank you
P.S
i need the "strbody" to be align left
Sub mail_person()
Dim a As Integer, b As Integer
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String, combine As String, item As String, item_name As String, strbody1 As String
a = 1
If arr > 1 Then
For concatenate = a To arr - 1
x = x & "LRU Name : " & LRU1(a) & " " & "Quantity : " & LRU_quantity(a) & Chr(10)
a = a + 1
Next
Else
x = ""
End If
item = Worksheets("sheet1").Range("b2").Value
item_name = Worksheets("sheet1").Range("b3").Value
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
strbody = "Hello" & vbNewLine & vbNewLine & _
"This email was sent to update you on obsolite items " & _
"in your project : " & pro_code & vbNewLine & _
"Inventory : " & inventory & vbNewLine & _
"price : " & price & vbNewLine & _
"LRU Name : " & pro_inner_code & " " & "Quantity : " & sum_quantity & vbNewLine & _
x & vbNewLine & vbNewLine & _
"Best regards" & vbNewLine & vbNewLine & name
On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Program Obsolite Update -" & item
.Body = strbody & strbody1
.display 'or use .sent
End With
On Error GoTo 0
End Sub
Edit: VBA tags added to code. Select your code when posting and hit the vba button to format it for the forum.
i wrote a code which transfer data from excel to outlook email body.
i have to align the text to the right, but i don't know how.
Thank you
P.S
i need the "strbody" to be align left
Sub mail_person()
Dim a As Integer, b As Integer
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String, combine As String, item As String, item_name As String, strbody1 As String
a = 1
If arr > 1 Then
For concatenate = a To arr - 1
x = x & "LRU Name : " & LRU1(a) & " " & "Quantity : " & LRU_quantity(a) & Chr(10)
a = a + 1
Next
Else
x = ""
End If
item = Worksheets("sheet1").Range("b2").Value
item_name = Worksheets("sheet1").Range("b3").Value
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
Set OutMail = OutApp.CreateItem(0)
strbody = "Hello" & vbNewLine & vbNewLine & _
"This email was sent to update you on obsolite items " & _
"in your project : " & pro_code & vbNewLine & _
"Inventory : " & inventory & vbNewLine & _
"price : " & price & vbNewLine & _
"LRU Name : " & pro_inner_code & " " & "Quantity : " & sum_quantity & vbNewLine & _
x & vbNewLine & vbNewLine & _
"Best regards" & vbNewLine & vbNewLine & name
On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Program Obsolite Update -" & item
.Body = strbody & strbody1
.display 'or use .sent
End With
On Error GoTo 0
End Sub
Edit: VBA tags added to code. Select your code when posting and hit the vba button to format it for the forum.