On Mar 22, 9:13 am, Eddy Stan <EddyS...@discussions.microsoft.com>
wrote:
> hi
> i am trying to send mail from excel file
[quoted text clipped - 75 lines]
>
> advance thanks
Hello Eddy Stan,
The For Each Loop above the one generating the error has the same
control value name CELL. Change the name of the Control value in the
loop causing the error. For example...
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
' TO CHOOSE MATTER TO PRINT IN MAIL BODY
For Each C In
ThisWorkbook.Sheets("Sheet1").Range("D3:D5")
strbody = strbody & cell.Value & vbNewLine
Next C
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sincerely,
Leith Ross
Eddy Stan - 24 Mar 2008 15:16 GMT
> Hello Eddy Stan,
>
[quoted text clipped - 11 lines]
> Sincerely,
> Leith Ross
Sub TestFile()
Dim OutApp As Object
Dim OutMail As Object
Dim cell As Range
Dim strto As String
Dim strbody As String
Application.ScreenUpdating = False
Set OutApp = CreateObject("Outlook.Application")
OutApp.Session.Logon
On Error GoTo cleanup
' For Each cell In
Sheets("Sheet1").Columns("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" And LCase(cell.Offset(0, 1).Value) =
"yes" Then
' TO CHOOSE DIFFERENT TO-MAIL ID
For Each cell In ThisWorkbook.Sheets("Sheet1") _
.Range("B3:B5").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "?*@?*.?*" Then
strto = strto & cell.Value & ";"
End If
' TO CHOOSE MATTER TO PRINT IN MAIL BODY
For Each C In ThisWorkbook.Sheets("Sheet1").Range("D3:D5")
strbody = strbody & cell.Value & vbNewLine
Next C
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = strto
.Subject = "Reminder"
.body = "Dear " & cell.Offset(0, -1).Value & vbNewLine &
vbNewLine & _
"Please contact us to discuss bringing your account
up to date"
' You can add files also like this
' .Attachments.Add ("C:\test.txt")
.Send 'Or use Display
End With
On Error GoTo 0
If Len(strto) > 0 Then strto = Left(strto, Len(strto) - 1)
Set OutMail = Nothing
' End If
Next cell
End If
cleanup:
Set OutApp = Nothing
Application.ScreenUpdating = True
End Sub
I have changed as you have advised and the error is not coming but at the
same time the mail is being processed.
please into the above code.
Eddy Stan - 24 Mar 2008 15:43 GMT
Hi
I have changed as you have advised. The error is not coming up but at the
same time the mail is NOT being processed.