Formatting issue when sending e-mail via CDO to Excel 2007


Michael Lanier

When I use CDO to send email, the method works fine with Excel 2003
(although the rows of text are somewhat spaced further apart than the
original). But my Excel 2007, when receiving my CDO generated email
radically restructures the page. (Hidden password protected columns
become visible; words on rows are repositioned somewhat similar to
word wrap; etc.) The macro I use in my Excel 2003 to generate the
email was adapted from one Ron Debruin has on his website. I can only
assume I've neglected to address something of significance. The
adapted macro follows:

Private Sub Worksheet_Change(ByVal TargetCell As Range)
If Worksheets("DataBase").Range("R347").Value = 0 And Worksheets
("Record").Range("C21").Value > 0 Then
Dim iMsg As Object
Dim iConf As Object
Dim ws As Worksheet
Dim Sourcewb As Workbook
Dim Flds As Variant
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
sendusing") = 2
smtpserver") = Worksheets("Registration").Range("J38")
smtpserverport") = 25
End With
Set Sourcewb = ThisWorkbook
For Each ws In Sourcewb.Worksheets
If ws.Range("AF50").Value Like "?*@?*.?*" Then
With iMsg
Set .Configuration = iConf
.To = ws.Range("AF50").Value
.From = Worksheets("Record").Range("AC52")
.Subject = "The " & Worksheets("Record").Range
("C5") & " Project"
.HTMLBody = RangetoHTML(ws.UsedRange)
End With
Set iMsg = Nothing
End If
Next ws
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
End If
End Sub

Any help would be much appreciated. Thanks.


Ron de Bruin

Hi Michael

Not notice this, can you send me a example file private and tell me what is wrong

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads