Results 1 to 10 of 10

Raplace Variables in HTML template With values from excel

Threaded View

  1. #1
    Valued Forum Contributor Steffen Thomsen's Avatar
    Join Date
    10-15-2010
    Location
    Kolding, Denmark
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    953

    Raplace Variables in HTML template With values from excel

    Hi

    I have the a problem for which i need some help.

    Sub Send_mail()
        
        ' This code goes threw mail adresses in column B and sends a HTML template as body text to them.
        Dim iMsg As Object
        Dim iConf As Object
        Dim strbody As String
    
        Set iMsg = CreateObject("CDO.Message")
        Set iConf = CreateObject("CDO.Configuration")
    
            iConf.Load -1
            Set Flds = iConf.Fields
            With Flds
                .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
                .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
                               = "My smtp mail server"
               .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
                .Update
            End With
        
        Range("B1").Select
        
        Do Until IsEmpty(ActiveCell)
        With iMsg
            Set .Configuration = iConf
            .To = ActiveCell.Text
            .CC = ""
            .BCC = ""
            .From = """Me"" <my@email.com>"
            .Subject = "Type subject here"
            .CreateMHTMLBody "file://C:/My template file path"
            
            .Send
        End With
        ActiveCell.Offset(1, 0).Select
        Loop
    
    End Sub
    What i need is something in the code that replaces a variable in the HTML Template [FirstName] with the Name in column A.

    Any help is welcome

    Steffen Thomsen
    Last edited by Steffen Thomsen; 11-18-2010 at 11:28 AM.

Thread Information

Users Browsing this Thread

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

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