Results 1 to 2 of 2

Attachments when sending mails with 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

    Attachments when sending mails with excel

    Hi,
    I have a problem i could need some help with.

    I have this code:

        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") _
                               = "Myoutgoing"
               .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
                .Update
            End With
    
        sq = Columns(2).SpecialCells(2).Offset(, -1).Resize(, 2)
            Open "file:///C:/MyHtmlTemplate.html" For Input As #1
            c01 = Input(LOF(1), #1)
            Close #1
    
         For j = 1 To UBound(sq)
             Open "file:///C:/Temp/MyHtmlTemplate.html" & j & ".html" For Output As #1
             Print #1, Replace(c01, "[userName]", sq(j, 1))
         Close #1
        
         With iMsg
            Set .Configuration = iConf
            .to = sq(j, 2)
            .From = """You"" <you@mail.com>"
            .Subject = "Subject"
            .CreateMHTMLBody "file:///C:/Temp/MyHtmlTemplate.html" & j & ".html"
            .Send
        End With
      Next
      
        On Error Resume Next
        Kill "C:/Users/Steffen/Documents/Data_til_mail_test/Mails/Skraldespand/*.*"
        On Error GoTo 0
    This goes threw a list of mails in my worksheet and sends them a personlaize mail of the template.

    Now the problem is in my template i have a signature (Images).

    when i send to multiple mailadresses the first gets the mail as expected, number 2 gets the mails as expected and an attached signature. number 3 gets 2 attached signatures.

    It's seem the signature isn't killed after every send.

    Any help?

    Steffen Thomsen.
    Last edited by Steffen Thomsen; 03-08-2011 at 05:27 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