LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help required for automated mailing list

Hello everyone,
I have a macro which send out automated mails to each recipient as
shown below. The macro runs well for the recipient as long as the file
associated with their name is there. Now my problem is if there is no
file associated with the recipient's name from my recipient list, then
the macro stops running in the middle giving me the message that there
is no file associated with the recipient or that the file intended for
the recipient is missing. Now , I would request you guys to help me out
so that the macro runs for all the recipients list skipping whoever is
not there in the list or whose file associated with the recipient is
missing. Thanks

Public Sub AutoMail()
Dim oOutlookApp As New Outlook.Application
Dim strBody As String
'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)
Windows("Macro file for SMs weekly report.xls").Activate
Range("B273").Activate
While ActiveCell.Value < ""
varSMId = ActiveCell.Value
varSMName = ActiveCell.Offset(0, 1).Value
varEMail = ActiveCell.Offset(0, 2).Value
varAsonDate = Format(ActiveCell.Offset(0, 3).Value,
"dd-mm-yy")
varBranch = ActiveCell.Offset(0, 4).Value

lcAttachment = ""
lcAttachment = "C:\All SMs with codes week 4 May 04\" & varSMId
& ".xls"
If Not lcAttachment = "" Then
Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
'Set the recipient for the new email
To = varEMail
'Set the recipient for a copy
'.CC = "
'Set the subject
Subject = "Sales Performance as on date " &
varAsonDate
'The content of the document is used as the body for
the email
Body = strBody
Attachments.Add lcAttachment
Send
End With
Application.ScreenUpdating = True
Set OutMail = Nothing
Set OutApp = Nothing
End If

ActiveCell.Offset(1, 0).Activate
Wend

End Sub


---
Message posted from http://www.ExcelForum.com/

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need to import my Excel Mailing list into mailing label format. Gord Dibben Excel Discussion (Misc queries) 0 November 5th 09 10:16 PM
I need to import my Excel Mailing list into mailing label format. Lyn Excel Discussion (Misc queries) 0 November 5th 09 08:11 PM
Producing an automated list from a large list Chuckee Excel Worksheet Functions 0 February 26th 07 04:00 PM
Producing an automated list from a larger list Chuckee Excel Worksheet Functions 2 February 26th 07 12:31 PM
Customer profiles with automated follow up mailing or call bks parteemiz Excel Discussion (Misc queries) 1 November 20th 05 12:20 AM


All times are GMT +1. The time now is 09:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"