MaunishP
Member
Hi Team,
I am clubbing my previous thread here, due to Thread name i have posted incorrect, hence there were no views towards it.
http://chandoo.org/forum/threads/send-mail-from-excel-to-outlook.22962/
Here goes my query :
I have an excel file each month with three different worksheet. I need to send emails to my vendor at every bi-hour regarding today's work performed. I would like to have a VBA code which will select data by going into all 3 worksheets selecting today's data.
I have attached sample excel file which i require.
I have a code which will allow me to send emails using microsoft excel, now i would like to have above given query code to club with below given code >
Note to be taken :
Total 4 mails data should be send with different data
1st data should be taken from Mail 1 Worksheet for today's date
2nd data should be taken from Mail 2 Worksheet for today's date
3rd data should be taken from Mail 3 and 4 only for CCTV vendor for today's date
4th data should be taken from Mail 3 and 4 only for Tea and AC Vendor for today's date
Regards,
Maunish Patel
I am clubbing my previous thread here, due to Thread name i have posted incorrect, hence there were no views towards it.
http://chandoo.org/forum/threads/send-mail-from-excel-to-outlook.22962/
Here goes my query :
I have an excel file each month with three different worksheet. I need to send emails to my vendor at every bi-hour regarding today's work performed. I would like to have a VBA code which will select data by going into all 3 worksheets selecting today's data.
I have attached sample excel file which i require.
I have a code which will allow me to send emails using microsoft excel, now i would like to have above given query code to club with below given code >
Note to be taken :
Total 4 mails data should be send with different data
1st data should be taken from Mail 1 Worksheet for today's date
2nd data should be taken from Mail 2 Worksheet for today's date
3rd data should be taken from Mail 3 and 4 only for CCTV vendor for today's date
4th data should be taken from Mail 3 and 4 only for Tea and AC Vendor for today's date
Code:
Sub Preview()
I = Cells(2, "B").Value ' dynamising startrownumber to user fed value at cell B2
Do ' start the action ,buddy!!!!
Subj = Cells(I, "A").Value
Filepath = Cells(I, "B").Value
EmailTo = Cells(I, "C").Value
CCto = Cells(I, "D").Value
msg = Cells(I, "E").Value
Application.DisplayAlerts = False' hey macro ,i dont wanna make you take time ,so this command to save time to avoid displays
Dim OutApp AsObject
Dim OutMail AsObject
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
OnErrorResumeNext
With OutMail
.To = EmailTo
.CC = CCto
.BCC = ""
.Subject = Subj
.body = msg
.Attachments.Add Filepath
.display
EndWith
OnErrorGoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
Application.DisplayAlerts = True
I = I + 1
Cells(1, "A").Value = "Outlook sent Time,Dynamic msg preview count =" & I - 3
LoopUntil Cells(I, "C").Value = ""
EndSub
Regards,
Maunish Patel