Results 1 to 2 of 2

Export from Excel to Outlook, Outlook has to be running?

Threaded View

  1. #1
    Registered User
    Join Date
    01-03-2013
    Location
    Germany
    MS-Off Ver
    Excel 2007
    Posts
    13

    Question Export from Excel to Outlook, Outlook has to be running?

    Hi,

    somehow I have a weird issue here. I just set up my first macro which generates some emails out of a list. The macro works actually pretty good, however as soon as I close outlook it doesnt work correctly anymore.

    The macro should (in this example) generate three emails and save them in the template folder. As long as outlook is running this is working, however if outlook is closed two emails are saved in the template folder and one email is saved in the inbox folder (see screenshots).

    Does anybody have a solution for that? highly appreciated!

    Code, File, Screenshots, pls see attached!

    Option Explicit
    Sub emails_erstellen()
    Dim i As Long
    Dim app As Outlook.Application
    Dim mail As Outlook.MailItem
    
    With ActiveSheet
    
        'Outlook starten
        Set app = CreateObject("Outlook.Application")
        
        'For i = 2 To Cells(Rows.Count, 1).End(xlUp).Row
        For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
        
            'E-Mail Aufrufen
            Set mail = app.CreateItem(olMailItem)
            
            'E-Mail Eigenschaften
            mail.To = .Cells(i, 4)
            mail.Subject = "Unternehmen | unser Telefongespräch"
            mail.Body = .Cells(i, 1) & " " & .Cells(i, 2)
            
            'E-Mail: Anhang hinzufuegen (IF-Struktur)
            If .Cells(i, 5).Value = "x" Then
            mail.Attachments.Add ThisWorkbook.Path & "\test.txt"
            End If
            
            'E-Mail in Entwurf abspeichern
            mail.Save
        
        Next i
    
    End With
    Attached Images Attached Images
    Attached Files Attached Files

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