Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel Macros sending attachments to multiple e-mail addressescontained in one cell.

Hi there!

I have this Excel Macros which is designed to send an attachment to
someone's e-mail address. In this case, the title of the attachment is
identical to the name of the person to who I am sending it to.

My active worksheet only uses two ranges, A and B. Down column A
lists the names of people; each cell in column A contains one person's
name. Down Column B lists each person's corresponding e-mail address;
each cell in column B contains one e-mail address. The code below
works just fine for that.

Unfortunately, there may be more than one e-mail addresses contained
in each B cell. Any suggestions?

Sub SendEmailWithAttachment()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim strEmail As String, strName As String
Dim lRowCount As Long


Set objOutlook = CreateObject("outlook.application") ' Start
outlook


lRowCount = 2 ' Change to starting ROW containing email address/
name


Do Until ActiveSheet.Cells(lRowCount, 2) = "" ' check for email,
End if none found
strEmail = ActiveSheet.Cells(lRowCount, 2).Value ' get email
address
strName = ActiveSheet.Cells(lRowCount, 1).Value ' get client name
Set objOutlookMsg = objOutlook.CreateItem(olMailItem) ' create
new email msg
With objOutlookMsg ' Fill email


.Subject = "Put this text in subject line" ' Note: Could be
column "C" - ActiveSheet.Cells(lRowCount, 3).Value
.Body = "Put this text in body of email" ' Note: Could be
column "D" - ActiveSheet.Cells(lRowCount, 4).Value

.To = strEmail
.Attachments.Add ("c:/e-mail attachments/" & strName & ".xls")
.Send
End With
lRowCount = lRowCount + 1 ' Increment Row Counter
Loop


objOutlook.Quit
Set objOutlook = Nothing
Set objOutlookMsg = Nothing
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Excel Macros sending attachments to multiple e-mail addresses contained in one cell.

Do you have duplicate rows with the same mail addresss in B ?
Am I understand you correct ?

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


wrote in message ...
Hi there!

I have this Excel Macros which is designed to send an attachment to
someone's e-mail address. In this case, the title of the attachment is
identical to the name of the person to who I am sending it to.

My active worksheet only uses two ranges, A and B. Down column A
lists the names of people; each cell in column A contains one person's
name. Down Column B lists each person's corresponding e-mail address;
each cell in column B contains one e-mail address. The code below
works just fine for that.

Unfortunately, there may be more than one e-mail addresses contained
in each B cell. Any suggestions?

Sub SendEmailWithAttachment()
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim strEmail As String, strName As String
Dim lRowCount As Long


Set objOutlook = CreateObject("outlook.application") ' Start
outlook


lRowCount = 2 ' Change to starting ROW containing email address/
name


Do Until ActiveSheet.Cells(lRowCount, 2) = "" ' check for email,
End if none found
strEmail = ActiveSheet.Cells(lRowCount, 2).Value ' get email
address
strName = ActiveSheet.Cells(lRowCount, 1).Value ' get client name
Set objOutlookMsg = objOutlook.CreateItem(olMailItem) ' create
new email msg
With objOutlookMsg ' Fill email


.Subject = "Put this text in subject line" ' Note: Could be
column "C" - ActiveSheet.Cells(lRowCount, 3).Value
.Body = "Put this text in body of email" ' Note: Could be
column "D" - ActiveSheet.Cells(lRowCount, 4).Value

.To = strEmail
.Attachments.Add ("c:/e-mail attachments/" & strName & ".xls")
.Send
End With
lRowCount = lRowCount + 1 ' Increment Row Counter
Loop


objOutlook.Quit
Set objOutlook = Nothing
Set objOutlookMsg = Nothing
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Excel Macros sending attachments to multiple e-mail addressescontained in one cell.

On Jan 17, 10:52*pm, "Ron de Bruin" wrote:
Do you have duplicate rows with the same mail addresss in B ?
Am I understand you correct ?

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm



wrote in ...
Hi there!


I have thisExcelMacroswhich is designed to send an attachment to
someone'se-mailaddress. In this case, the title of the attachment is
identical to the name of the person to who I am sending it to.


My active worksheet only uses two ranges, A and B. *Down column A
lists the names of people; each cell in column A contains one person's
name. Down Column B lists each person's correspondinge-mailaddress;
each cell in column B contains onee-mailaddress. *The code below
works just fine for that.


Unfortunately, there may be more than onee-mailaddresses contained
in each B cell. *Any suggestions?


Sub SendEmailWithAttachment()
*Dim objOutlook As Outlook.Application
*Dim objOutlookMsg As Outlook.MailItem
*Dim strEmail As String, strName As String
*Dim lRowCount As Long


*Set objOutlook = CreateObject("outlook.application") *' Start
outlook


*lRowCount = 2 *' Change to starting ROW containingemailaddress/
name


*Do Until ActiveSheet.Cells(lRowCount, 2) = "" *' check foremail,
End if none found
* *strEmail = ActiveSheet.Cells(lRowCount, 2).Value *' getemail
address
* *strName = ActiveSheet.Cells(lRowCount, 1).Value *' get client name
* *Set objOutlookMsg = objOutlook.CreateItem(olMailItem) *' create
newemailmsg
* *With objOutlookMsg *' Fillemail


* * *.Subject = "Put this text in subject line" *' Note: Could be
column "C" - ActiveSheet.Cells(lRowCount, 3).Value
* * *.Body = "Put this text in body ofemail" *' Note: Could be
column "D" - ActiveSheet.Cells(lRowCount, 4).Value


* * *.To = strEmail
* * *.Attachments.Add ("c:/e-mailattachments/" & strName & ".xls")
* * *.Send
* *End With
* *lRowCount = lRowCount + 1 *' Increment Row Counter
*Loop


*objOutlook.Quit
*Set objOutlook = Nothing
*Set objOutlookMsg = Nothing
End Sub- Hide quoted text -


- Show quoted text -


I figured it out Ron. Sorry to waste your time. The code works just
fine. There could be more than one e-mail address in each b cell in
some circumstances. When I was running some tests, it seemed to work
if I did not use a hyper link (i.e., just had the e-mail address in
simple text) and used the semi colon ; to separate each e-mail address
contained in one B cell. If it doesn't work the next time I try, then
I'll leave a message again (but I think it will). Thanks again
Ron! :)

Reply
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
Sending Templates as e-mail Attachments? Excel Template as an e-mail Attachment Excel Discussion (Misc queries) 0 September 5th 07 10:56 PM
E-mail macro - how do I attach multiple attachments? G and (ajk) Excel Discussion (Misc queries) 1 October 9th 06 01:22 PM
send mail from excel 2000 with multiple attachments ...Patrick[_7_] Excel Programming 6 May 20th 06 12:10 PM
E-mail Multiple Attachments STEVEB Excel Programming 2 December 2nd 05 03:17 PM
Multiple attachments in Excel e-mail? Peter[_42_] Excel Programming 1 June 12th 04 12:22 PM


All times are GMT +1. The time now is 10:02 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"