View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Edgar Thoemmes Edgar Thoemmes is offline
external usenet poster
 
Posts: 12
Default Out of Memory Error

Hi

I have the following code to send files direct from excel
but when I run this it comes up with the error 'Out of
Memory' does any have any ideas why this is happening?

Code:

Sub AutoSend()
Dim olApp As Outlook.Application
Dim olMail As MailItem
Dim cell As Range
Application.ScreenUpdating = False
Set olApp = New Outlook.Application
For Each cell In Sheets("Sheet1").Columns
("B").Cells.SpecialCells(xlCellTypeConstants)
If cell.Offset(0, 1).Value < "" Then
If cell.Value Like "*@*" And Dir(cell.Offset
(0, 1).Value) < "" Then
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = cell.Value
.Subject = "Remittance Advice"
.Body = "Please see the attached
Remittance advice and Cover Note"
.Attachments.Add cell.Offset(0,
1).Value
.Attachments.Add ("c:\remit\Remittance
Cover Note.doc")
.Display 'Or use Display
End With
Set olMail = Nothing
End If
End If
Next cell
Set olApp = Nothing
Application.ScreenUpdating = True
End Sub