Results 1 to 14 of 14

Outlook Mail Automation Modification

Threaded View

  1. #1
    Registered User
    Join Date
    12-19-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    53

    Outlook Mail Automation Modification

    Hi All,

    I have modified a VBA code from Ron de Bruin Excel Automation.

    Its working fine but I want to add something more in this. Please help me to add below steps.

    ".to" is taking value from column B of excel Sheet 1.
    1) So I want ".cc" should take value from column D,
    2) ".bcc" should take value from column E and ".
    3) ".Subject" should take value from column F.

    Below is modified code from http://www.rondebruin.nl/win/s1/outlook/amail6.htm

    Sub Mail_Outlook_With_Signature_Html()
    
        Dim OutApp As Object
        Dim OutMail As Object
        Dim strbody As String
        Dim sh As Worksheet
        Dim cell As Range
        Dim FileCell As Range
        Dim rng As Range
        
        With Application
            .EnableEvents = False
            .ScreenUpdating = False
        End With
        
        Set sh = Sheets("Sheet1")
        
        Set OutApp = CreateObject("Outlook.Application")
            
        For Each cell In sh.Columns("B").Cells.SpecialCells(xlCellTypeConstants)
    
            'Enter the path/file names in the C:Z column in each row
            Set rng = sh.Cells(cell.Row, 1).Range("C1:Z1")
    
            If cell.Value Like "?*@?*.?*" And _
               Application.WorksheetFunction.CountA(rng) > 0 Then
                Set OutMail = OutApp.CreateItem(0)
        
        strbody = "<br>Hello,</br>" & _
                  "<p>My name is Liz.<br></p>" & _
                  "<p></p>"
    
        On Error Resume Next
    
        With OutMail
            .Display
            .to = cell.Value
            .CC = ""
            .BCC = ""
            .Subject = ""
            .HTMLBody = strbody & "<br>" & .HTMLBody
        
        For Each FileCell In rng.SpecialCells(xlCellTypeConstants)
                        If Trim(FileCell) <> "" Then
                            If Dir(FileCell.Value) <> "" Then
                                .Attachments.Add FileCell.Value
                            End If
                        End If
                    Next FileCell
    
                    .Send  'Or use .Display
                End With
                
                On Error GoTo 0
                Set OutMail = Nothing
                Set OutApp = Nothing
            End If
        Next cell
    
        Set OutApp = Nothing
        With Application
            .EnableEvents = True
            .ScreenUpdating = True
        End With
        
    End Sub
    Thanks,
    Liz.
    Last edited by Liz_Biz; 04-15-2014 at 08:46 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Outlook 2007, Referencing mail Item created from outlook template
    By thusidie in forum Outlook Programming / VBA / Macros
    Replies: 2
    Last Post: 07-21-2014, 04:33 PM
  2. Send e-mail with image on body (.html) on e-mail manager <> outlook
    By mariotnc in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-05-2012, 09:28 PM
  3. code to attach the draft mail in new compose mail as attachment in outlook 2010
    By priya1987 in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 10-10-2012, 08:38 AM
  4. Outlook Automation Error Problem - Can't locate Outlook Module
    By Allan P. London in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-14-2005, 06:05 PM
  5. Excel Template modification using automation
    By Terry Holland in forum Excel General
    Replies: 1
    Last Post: 03-30-2005, 02:06 PM

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