Home |
Search |
Today's Posts |
|
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Edgar
Look in the VBA help for the Offset function. Try to understand it Post back if you need more help 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(x lCellTypeConstants) 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 http://www.rondebruin.nl/sendmail.htm#file -- Regards Ron de Bruin (Win XP Pro SP-1 XL2000-2003) www.rondebruin.nl "Edgar" wrote in message ... Hi I use the following code to send emails from Excel. The sheet that it uses has the following columns: SuppID Name Email Curr Amount File Location 112585 AAA AUD 3000 C:\remit\112585.msg 112652 BBB , NZD 5000 c:\remit\112652.msg When i run the code it checks that there is an email address in column C and a file location in column F and then loops through the items sending an email with the data in the list. I have used this before but i changed the layout of the sheet to add some extra columns and adjusted the offset values in the code but now when I run the code it doesnt pick up the right file as an attachment. Can anyone spot why this is happening? Thanks in advance 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 ("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 = "Testfile" .Body = "Hi " & cell.Offset(0, - 1).Value .Attachments.Add cell.Offset(0, 1).Value .Display 'Or use Display End With Set olMail = Nothing End If End If Next cell Set olApp = Nothing Application.ScreenUpdating = True End Sub |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
[To maximize your chances for meaninful answers, you should create a
new thread for a new subject.] Cursory reading of your code suggest that Offset(0,1) can't be right if you want to attach the file specified in column F. Why do you hinge your "For Each cell"-loop on column B? On Sun, 25 Jan 2004 08:22:21 -0800, "Edgar" wrote in microsoft.public.excel.programming: Hi I use the following code to send emails from Excel. The sheet that it uses has the following columns: SuppID Name Email Curr Amount File Location 112585 AAA AUD 3000 C:\remit\112585.msg 112652 BBB , NZD 5000 c:\remit\112652.msg When i run the code it checks that there is an email address in column C and a file location in column F and then loops through the items sending an email with the data in the list. I have used this before but i changed the layout of the sheet to add some extra columns and adjusted the offset values in the code but now when I run the code it doesnt pick up the right file as an attachment. Can anyone spot why this is happening? Thanks in advance 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 ("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 = "Testfile" .Body = "Hi " & cell.Offset(0, - 1).Value .Attachments.Add cell.Offset(0, 1).Value .Display 'Or use Display End With Set olMail = Nothing End If End If Next cell Set olApp = Nothing Application.ScreenUpdating = True End Sub -- Michael Bednarek http://mbednarek.com/ "POST NO BILLS" |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
send email to each customer email in excel sheet. | Excel Discussion (Misc queries) | |||
Email addresses in Excel need to format for mass email | Excel Worksheet Functions | |||
Email editor closes when forwarding Excel-embedded email | Setting up and Configuration of Excel | |||
working on excel document in email saved changes in email not in . | Excel Discussion (Misc queries) | |||
body of email disappears when I send an email from Excel | Excel Discussion (Misc queries) |