Dansk Regneark Forum
  Hjælp Hjælp  Søg i forum   Opret ny bruger Opret ny bruger  Log ind Log ind


Emne lukketHjælp til at sende email fra excel

 Besvar Besvar
Forfatter
rashid3105 Se dropdown
Forum Begynder
Forum Begynder
Avatar

Medlem: 19.Sep.2014
Land: Danmark
Status: Offline
Point: 1
Direkte link til dette indlæg Emne: Hjælp til at sende email fra excel
    Sendt: 19.Sep.2014 kl. 11:35
jeg ønsker at sende en mail til en liste af modtagere, hvor den kun skal sendes, hvis første celle (A2) ikke er tom.

jeg har benyttet denne kode:
Sub Test2()
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
'Working in Office 2000-2013
    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range

    Application.ScreenUpdating = False
    Set OutApp = CreateObject("Outlook.Application")

    On Error GoTo cleanup
    For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
        If cell.Value Like "?*@?*.?*" And _
           LCase(Cells(cell.Row, "C").Value) = "yes" _
           And LCase(Cells(cell.Row, "D").Value) <> "send" Then

            Set OutMail = OutApp.CreateItem(0)

            On Error Resume Next
            With OutMail
                .To = cell.Value
                .Subject = "Reminder"
                .Body = "Dear " & Cells(cell.Row, "A").Value _
                      & vbNewLine & vbNewLine & _
                        "Please contact us to discuss bringing " & _
                        "your account up to date."
                'You can add files also like this
                '.Attachments.Add ("C:\test.txt")
                .Send  'Or use Display
            End With
            On Error GoTo 0
            Cells(cell.Row, "D").Value = "send"
            Set OutMail = Nothing
        End If
    Next cell

cleanup:
    Set OutApp = Nothing
    Application.ScreenUpdating = True
End Sub

men sejler lidt i hvordan jeg kan differentiere om den første celle (A2) er tom eller ikke. Ved tom skal den springes over!!
samme for A3, A4 osv.
håber I kan hjælpe :)

Takker på forhånd!
Til top



Til top
EXCELGAARD Se dropdown
Platin bruger
Platin bruger


Medlem: 27.Dec.2012
Land: Denmark
Status: Offline
Point: 5491
Direkte link til dette indlæg Sendt: 20.Sep.2014 kl. 05:18
I den linje, hvor du tester for cellerne B-D, kan du osse bare teste for celle A:
If cell.Value Like "?*@?*.?*" And _
   LCase(Cells(cell.Row, "C").Value) = "yes" And _
   Cells(cell.Row, "A").Value) <> "" And_
   LCase(Cells(cell.Row, "D").Value) <> "send" Then
Husk, at trykke på [Tak], hvis du kan lide et indlæg.
Husk, at trykke på [Accepteret Svar], hvis du kan bruge et løsningsforslag.
Til top
 Besvar Besvar

Skift forum Forum tilladelser Se dropdown

© 2010 - 2026 Dansk Regneark Forum – en del af Excel-regneark.dk