SOLVED

Mailing excel sheets automatically to different recievers

Brass Contributor

I have lots of sheets and I need to send mail the sheets at the same time but different mail adresses according to the ''consignee'' column. 

 

As an example in photo below, Consignee column: AGILITY LOJISTIK ANONIM, and I wanna send mail this sheet to ''agility'' which is recorded in my outlook adresses book.  Is there a way to do it with the help of a formula or macro?

 

examplee.JPG

 

8 Replies

I am not so understand your problem. Can the column "Consignee" contains other receiver information?

Moreover, I am not sure the use of "name" in outlook address book. I have some experience to send different people with different attachment. But the file is not with me at home. 

 

You may refer to the following page:
                     https://www.rondebruin.nl/win/s1/outlook/mail.htm

I learn a lot from this page. 

 

Please let me know if you want me to send you some example. 

 

Thanks for your attention,

 

For example in Sheet1,  I see AGILITY LOJISTIK ANONIM AS in Consignee column it means I need to send this excel sheet to the firm which has already recorded in my adress book at outlook as "agility"

 

And if you have an example sheet it can be good for me.

You may refer to the attached file for reference.

Your example was very helpful for me.

 

Is it possible to change email content for every person we sent?

 

Like below,

 

Person: a@outlook.com - Email Content: good morning Mr A..

Person: b@outlook.com - Email Content: good night Mr B...

Of course you can. 

 

Set OA=CreateObject("Outlook.Application")

Set OM = OA.CreateItem(0)

 

With OM

    .to = email_address

    .subject = email_subject

    .body = email_content ' you may have use different cells for different people

end with

 

You may use "&" to concatenate different cells in .body

 

 

I changed the code like below but I am still need to apply for cells(i + 1, 10) and cells(i + 1, 11)  in .body part. How can I do this you have any idea?

 

For i = 1 To n_Staff
Set OA = CreateObject("Outlook.Application")
Set OM = OA.CreateItem(0)

With OM
.To = Info.Cells(i + 1, 7)
.Subject = Info.Range("M2")
.body = Info.Cells(i + 1, 9)

best response confirmed by Anıl Adaş (Brass Contributor)
Solution

If you want to send email involve Info.cells(i+1,9), Info.cells(i+1,10) and Info.cells(i+1,11), you may use "&" to concatenate the strings. 

 

.body = Info.cells(i+1,9) & chr(10) & Info.cells(i+1,10) & chr(10) & Info.cells(i+1,11)

 

"chr(10)" represents the line break after the content of Info.cells(i+1,9) (example). 

 

 

I was failed because I didn't use chr(10).

 

Thanks a lot..

1 best response

Accepted Solutions
best response confirmed by Anıl Adaş (Brass Contributor)
Solution

If you want to send email involve Info.cells(i+1,9), Info.cells(i+1,10) and Info.cells(i+1,11), you may use "&" to concatenate the strings. 

 

.body = Info.cells(i+1,9) & chr(10) & Info.cells(i+1,10) & chr(10) & Info.cells(i+1,11)

 

"chr(10)" represents the line break after the content of Info.cells(i+1,9) (example). 

 

 

View solution in original post