How to send a mail to some specific members.

satya12

Board Regular
Joined
Oct 19, 2021
Messages
70
Office Version
  1. 2016
Platform
  1. Windows
Hi All,

I am having "A" Col has mail id's and "B " Col has Date .
If we click on the button on the sheet , the macro will take "A" Col mail id's and In the body the date will be added in the message. is it possible.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Assuming that by "mail id's" you mean email addresses, try:
VBA Code:
Sub CreateEmails()
    Application.ScreenUpdating = False
    Dim OutApp As Object, OutMail As Object, LastRow As Long, ID As Range
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Set OutApp = CreateObject("Outlook.Application")
    For Each ID In Range("A2:A" & LastRow)
        Set OutMail = OutApp.CreateItem(0)
        With OutMail
            .To = ID.Value
            .Subject = "Date"
            .HTMLBody = ID.Offset(, 1).Value
            .Display
        End With
    Next ID
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Thanks for your help! its working fine , but can you please tell me how to send grp mails and adding user input box in the macro for date .like in the A col we are having 10 mails and B col having some dates different or repeated , in that time macro have to ask which date should be added to the body of the mail.

MailsDates
ABC@gamil.com19th Jan
DEF@gmail.com20th Jan
GHI@gmail.com19th Jan

Data will look like this..macro will do take the all the mails at a time, and in the body macro have to ask date which date have been add to mail body , we will give date like 19th jan , after then the mail will send automatically.
 
Upvote 0
Try:
Rich (BB code):
Sub CreateEmails()
    Application.ScreenUpdating = False
    Dim OutApp As Object, OutMail As Object, LastRow As Long, ID As Range, d As Date, response As String
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    response = InputBox("Enter the date in the format: yyyy/mm/dd")
    If response = "" Then Exit Sub
    Set OutApp = CreateObject("Outlook.Application")
    For Each ID In Range("A2:A" & LastRow)
        Set OutMail = OutApp.CreateItem(0)
        With OutMail
            .To = ID.Value
            .Subject = Date
            .HTMLBody = Format(response, "Mmm dd")
            .Display
        End With
    Next ID
    Application.ScreenUpdating = True
End Sub
Change .Display (in red) to .Send if you want to send the emails instead of displaying them.
 
Upvote 0
thanks for your help! its working fine. But it is taking one by one mail from Col "A", but i want All the mails in the Col-"A" will take and send all the mail at a time in one mail
 
Upvote 0
Unfortunately, that's not possible. The emails have to be created one at a time.
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,186
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top