Send different emails to different email ID"s from Excel

Sumit Dey

New Member
Joined
Nov 1, 2019
Messages
17
Hi everyone,

I know how to send emails to several emails ID's at a time using VBA... But, I am looking to send different emails to each email ID/ID's at once. Like we do in a mail merge.

Currently I am using mail merge whereas, some sections of the email are fixed and are taken from an word file but, some other parts of the email had to be different and here we use the data from an excel file. We merge data from the word file and the excel file and send them all at once.

I would be thankful if someone can find an alternate way of doing the same using the Excel vba alone.

Thanks a lot in advance
 

James006

Well-known Member
Joined
Apr 4, 2009
Messages
3,680
Hi,

Your question is so vague ...it will be difficult for any contributor to provide a solution ...
 

Sumit Dey

New Member
Joined
Nov 1, 2019
Messages
17
Sorry for any confusion I'll try to explain my question here...

I have an Excel where I have an commandbutton clicking which I send a particular (same) email to multiple receivers.

What I need here is that when I click the commandbutton I shall be able to send each receiver a different email and not a same email to everyone.

I hope I made myself clear here...
 

Sumit Dey

New Member
Joined
Nov 1, 2019
Messages
17
The code I am using:

Sub SendEmails()

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
'Input email ids here and use ";" is case email need to send multiple users
.To = "test.test@test.com
.CC = "Email2@gmail.com"
.BCC = "Email3@gmail.com"
'Subject Line comes here
.Subject = "Email Subject Line"

'email body comes here use "vblf" for multi-line text
.Body = "Body Text Line 1" & _
vbLf & "Text Line 2" & _
vbLf & "Text Line 3"

'attachments here
.Attachments.Add ("C:FilePathAttachmentFile.txt")


.Display '.Send

End With
On Error GoTo 0

'Free up the memory
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 

James006

Well-known Member
Joined
Apr 4, 2009
Messages
3,680
Within your macro ... you are dealing by definition with variables ...

So ..do no understand what is preventing you from adapting the variables such as :

.To and .Body
 

daverunt

Well-known Member
Joined
Jul 9, 2009
Messages
1,733
Hard-code the email as Mail1, Mail2 etc or use ranges where the text resides.

Use Select Case for the email address to determine which MailX is sent to said address.
 

Sumit Dey

New Member
Joined
Nov 1, 2019
Messages
17
Yeah got it... Thanks a lot...
One more question could you help me with a code wherein I can attach multiple attachments not just a single
 

daverunt

Well-known Member
Joined
Jul 9, 2009
Messages
1,733
Use a loop through a range of cells with the fullpath to the files or in this example selected files.

Code:
.Body = ""

AttachFileName = Application.GetOpenFilename("Files (*.**)," & _
"*.**", 1, "Select File", "Open", True)

For i = 1 To UBound(AttachFileName)
.Attachments.Add AttachFileName(i)
Next

.Display

End With
 
Last edited:

Forum statistics

Threads
1,082,587
Messages
5,366,486
Members
400,894
Latest member
frog9000

Some videos you may like

This Week's Hot Topics

Top