+ Reply to Thread
Results 1 to 4 of 4

Write E-mail addresses from a list

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    12-30-2013
    Location
    Falun, Sweden
    MS-Off Ver
    Excel 2007
    Posts
    112

    Write E-mail addresses from a list

    Hi,

    I have the following code to write e-mails.

    The receiver is "[email protected]" according to the program.

    I would like to change the program so I could pick up new addresses from a list in an excel sheet.

    .to = "[email protected]" would thus be changed to the first address in the list and so on.

    Could some one help me?

    Kind regards,

    Jan

    Sub Mail_workbook_Outlook_3()
    'Working in Excel 2000-2013
    'This example send the last saved version of the Activeworkbook
    'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
        Dim OutApp As Object
        Dim OutMail As Object
    
        Set OutApp = CreateObject("Outlook.Application")
        Set OutMail = OutApp.CreateItem(0)
        
        strbody = "Hej! <br><br>" & _
                  "TEXT"
    
        On Error Resume Next
        With OutMail
            .to = "[email protected]"
            .CC = ""
           .Subject = "Papper"
            .HTMLBody = strbody
            .Attachments.Add ("c:\bilaga\skyddsomslaget.pdf")
            '.Send
            .Display
        End With
        On Error GoTo 0
    
        Set OutMail = Nothing
        Set OutApp = Nothing
    End Sub

  2. #2
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Write E-mail addresses from a list

    Hi Jan

    Probably something like this...
    Option Explicit
    
    Sub Mail_workbook_Outlook_3()
       'Working in Excel 2000-2013
       'This example send the last saved version of the Activeworkbook
       'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
       Dim OutApp       As Object
       Dim OutMail      As Object
       Dim strbody      As String
       Dim cel          As Range
    
       Set OutApp = CreateObject("Outlook.Application")
       '   Set OutMail = OutApp.CreateItem(0)
    
       strbody = "Hej! <br><br>" & _
                 "TEXT"
    
       For Each cel In Sheet1.Range(("A2"), Sheet1.Range("A2").End(xlDown))
       
          Set OutMail = OutApp.CreateItem(0)
          On Error Resume Next
          With OutMail
             .to = cel.Value
             .CC = ""
             .Subject = "Papper"
             .HTMLBody = strbody
             .Attachments.Add ("c:\bilaga\skyddsomslaget.pdf")
             '.Send
             .Display
          End With
          On Error GoTo 0
    
       Next cel
    
       Set OutMail = Nothing
       Set OutApp = Nothing
    End Sub
    You'll need to tell the Code where your Email Addresses live...
    For Each cel In Sheet1.Range(("A2"), Sheet1.Range("A2").End(xlDown))
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  3. #3
    Forum Contributor
    Join Date
    12-30-2013
    Location
    Falun, Sweden
    MS-Off Ver
    Excel 2007
    Posts
    112

    Re: Write E-mail addresses from a list

    Hi,

    The program functions as planned.

    However, I have a further question.
    Is it possible to change the format of the item ".subject="Papper"" to become for instance, bold, italic, colored, size etc. ?

    With OutMail
             .to = cel.Value
             .CC = ""
             .Subject = "Papper"
             .HTMLBody = strbody
             .Attachments.Add ("c:\bilaga\skyddsomslaget.pdf")
             '.Send
             .Display
          End With
    Kind regards,
    Jan

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Write E-mail addresses from a list

    Hi Jan

    I'm not familiar with a way to do this...try to google it.
    Is it possible to change the format of the item ".subject="Papper"" to become for instance, bold, italic, colored, size etc. ?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Correct list of e-mail addresses
    By Vidhur100 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 05-29-2014, 03:51 AM
  2. Send to mail recipient, 1 worksheet, 2 cell ranges containing e-mail addresses
    By caladai in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-28-2013, 02:26 PM
  3. Opening e-mail addresses in a blank Outlook e-mail
    By Barking_Mad in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-03-2010, 11:59 AM
  4. Send list of E-mail Addresses to Microsoft Outlook
    By RIFRAF in forum Excel General
    Replies: 2
    Last Post: 09-29-2009, 11:59 AM
  5. Mail shot from list of email addresses
    By Mark Anderson in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-27-2008, 01:05 PM
  6. Replies: 4
    Last Post: 07-08-2008, 11:14 AM
  7. Send mail to specified mail addresses if a situation qualifies
    By mohitmahajan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-12-2007, 07:57 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1