I have the following macro assigned to a button. In cell I6, an email address is located. When the button is clicked, it should send the Ranges A1:I88 to the email address in I6.
The macro sends to correct address, fills out the "from" and "subject" correctly, but not the body. If I use .Textbody, every cell comes on a seperate line. If I use .HTMLbody, it eliminates every empty cell or line and everything is bunched together.
What i am trying to achieve, is to have the email body be an exact copy/layout as it is in excel. Anyone have an idea?
CODE:
Sub CDO_Mail_Small_Text()
Dim iMsg As Object
Dim iConf As Object
Dim Flds As Variant
Dim strbody As String
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "anyname"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "anypass"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "outgoing.triton.net"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With
Dim cell As Range
For Each cell In Sheets("Make - Invoice").Range("A1:I88")
strbody = strbody & cell.Value & vbNewLine
Next
With iMsg
Set .Configuration = iConf
.To = Sheets("Make - Invoice").Range("I6").Value
.CC = ""
.BCC = ""
.From = """Steve"" <[email protected]>"
.Subject = "test"
.TextBody = strbody
.Send
End With
End Sub
Bookmarks