ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Email from Excel att: Ron de Bruin (https://www.excelbanter.com/excel-programming/289138-email-excel-att-ron-de-bruin.html)

Edgar[_3_]

Email from Excel att: Ron de Bruin
 
Hi

I am still having trouble with my macro which sends emails
from excel!!

I have fixed the cell offset values but it is not
attaching the correct files to the email message. What i
cant understand is it is attaching files that are not in
the directory that i am specifying on the sheet. How can
this happen? Does anyone have any ideas?? (Code below)Sub
TestFile1()
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
("C").Cells.SpecialCells(xlCellTypeConstants)
If cell.Offset(0, 3).Value < "" Then
If cell.Value Like "*@*" And Dir(cell.Offset
(0, 3).Value) < "" Then
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = cell.Value
.Subject = "Testfile"
.Body = "Hi " & cell.Offset(0, -
1).Value
.Attachments.Add cell.Offset(0,
3).Value
.Display 'Or use Display
End With
Set olMail = Nothing
End If
End If
Next cell
Set olApp = Nothing
Application.ScreenUpdating = True
End Sub



Ron de Bruin

Email from Excel att: Ron de Bruin
 
Hi Edgar

I can't reproduce your problem
Send me your workbook private if you want.
I maybe can find your problem then

--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2000-2003)
www.rondebruin.nl



"Edgar" wrote in message ...
Hi

I am still having trouble with my macro which sends emails
from excel!!

I have fixed the cell offset values but it is not
attaching the correct files to the email message. What i
cant understand is it is attaching files that are not in
the directory that i am specifying on the sheet. How can
this happen? Does anyone have any ideas?? (Code below)Sub
TestFile1()
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
("C").Cells.SpecialCells(xlCellTypeConstants)
If cell.Offset(0, 3).Value < "" Then
If cell.Value Like "*@*" And Dir(cell.Offset
(0, 3).Value) < "" Then
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = cell.Value
.Subject = "Testfile"
.Body = "Hi " & cell.Offset(0, -
1).Value
.Attachments.Add cell.Offset(0,
3).Value
.Display 'Or use Display
End With
Set olMail = Nothing
End If
End If
Next cell
Set olApp = Nothing
Application.ScreenUpdating = True
End Sub






All times are GMT +1. The time now is 08:36 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com