• DİKKAT

    DOSYA İndirmek/Yüklemek için ÜCRETLİ ALTIN ÜYELİK Gereklidir!
    Altın Üyelik Hakkında Bilgi

Otomatik Mailin Body Kısmında Koşul

Katılım
13 Eylül 2015
Mesajlar
201
Excel Vers. ve Dili
2010 VBA
Arkadaşlar Merhaba,

Aşağıda otomatik mail hazırlayan bir makrom var. Body kısmında SG.Range ( "I21" den "I36" ya SG.Range ("J21")den "J36" ya kadar olan alan ile ilgili konuşuşuyorum. Şu haliyle çalıştırdığımda hücelerde ne varsa alt alta alıyor. Ancak hücrelerim boş ise boşluk bırakıyor. Ben istiyorum ki J21 den J36 ya kadar sadece dolu olan hücrelerim doluysa değer alsın dolu değilse atlasın ama boşluk bırakmasın.

Yardımlarınız için teşekkür ederim.




Kod:
Set xlOutlook = CreateObject("Outlook.Application")
    Set xlMail = xlOutlook.CreateItem(0)
    Set FSO = CreateObject("Scripting.FilesystemObject")
    Set imza = FSO.OpenTextFile("C:\Users\Desktop\imza\B2.htm", 1)
    With xlMail
        .sentonbehalfofname = ""
        .To = ""
        .Cc = SG.Range("E" & j).Value
        .bcc = SG.Range("g" & j).Value
        .Subject = SG.Range("C1") & " " & "Tarihli Toplantı Gündem Maddeleri Hakkında TEST AMAÇLIDIR"
        .HTMLBody = "<BODY style=font-size:11pt;font-family:Arial>" & "Sayın İlgili," & "<BR><BR>" & _
        "<B>" & Format(SG.Range("C1"), "dd.mm.yyyy") & " " & SG.Range("G1") & "</B> " & "günü " & "Toplantısında gündemi olan üniteler aşağıdaki gibidir." & "<BR><BR>" & _
        "İyi Çalışmalar," & "<BR><BR>" & _
        SG.Range("I21") & " " & SG.Range("J21") & "<BR>" & _
        SG.Range("I22") & " " & SG.Range("J22") & "<BR>" & _
        SG.Range("I23") & " " & SG.Range("J23") & "<BR>" & _
        SG.Range("I24") & " " & SG.Range("J24") & "<BR>" & _
        SG.Range("I25") & " " & SG.Range("J25") & "<BR>" & _
        SG.Range("I26") & " " & SG.Range("J26") & "<BR>" & _
        SG.Range("I27") & " " & SG.Range("J27") & "<BR>" & _
        SG.Range("I28") & " " & SG.Range("J28") & "<BR>" & _
        SG.Range("I29") & " " & SG.Range("J29") & "<BR>" & _
        SG.Range("I30") & " " & SG.Range("J30") & "<BR>" & _
        SG.Range("I31") & " " & SG.Range("J31") & "<BR>" & _
        SG.Range("I32") & " " & SG.Range("J32") & "<BR>" & _
        SG.Range("I33") & " " & SG.Range("J33") & "<BR>" & _
        SG.Range("I34") & " " & SG.Range("J34") & "<BR>" & _
        SG.Range("I35") & " " & SG.Range("J35") & "<BR>" & _
        SG.Range("I36") & " " & SG.Range("J36") & "<BR>" & _
        imza.readall
        .Save
        .Display
    End With
    
    Set xlMail = Nothing
    Set xlOutlook = Nothing
 
    With Application
        .EnableEvents = True
        .ScreenUpdating = True
    End With
    With Application
        .EnableEvents = False
        .ScreenUpdating = False
    End With
 
Bu kodu bir dene

Kod:
Set xlOutlook = CreateObject("Outlook.Application")
Set xlMail = xlOutlook.CreateItem(0)
Set FSO = CreateObject("Scripting.FilesystemObject")
Set imza = FSO.OpenTextFile("C:\Users\Desktop\imza\B2.htm", 1)


[COLOR="Red"]veri =[/COLOR] "<BODY style=font-size:11pt;font-family:Arial>" & "Sayın İlgili," & "<BR><BR>" & _
"<B>" & Format(SG.Range("C1"), "dd.mm.yyyy") & " " & SG.Range("G1") & "</B> " & "günü " & "Toplantısında gündemi olan üniteler aşağıdaki gibidir." & "<BR><BR>" & _
"İyi Çalışmalar," & "<BR><BR>"

[COLOR="red"]For i = 21 To 36
If SG.Cells(i, 9).Value <> "" And SG.Cells(i, 10).Value <> "" Then
veri = veri & SG.Cells(i, 9).Value & " " & SG.Cells(i, 10).Value & "<BR>"
End If
Next[/COLOR]


With xlMail
.sentonbehalfofname = ""
.To = ""
.Cc = SG.Range("E" & j).Value
.bcc = SG.Range("g" & j).Value
.Subject = SG.Range("C1") & " " & "Tarihli Toplantı Gündem Maddeleri Hakkında TEST AMAÇLIDIR"
.HTMLBody = "<BODY style=font-size:11pt;font-family:Arial>" & "Sayın İlgili," & "<BR><BR>" & _
"<B>" & Format(SG.Range("C1"), "dd.mm.yyyy") & " " & SG.Range("G1") & "</B> " & "günü " & "Toplantısında gündemi olan üniteler aşağıdaki gibidir." & "<BR><BR>" & _
"İyi Çalışmalar," & "<BR><BR>" & [COLOR="red"]veri [/COLOR]& imza.readall
.Save
.Display
End With

Set xlMail = Nothing
Set xlOutlook = Nothing

With Application
.EnableEvents = True
.ScreenUpdating = True
End With
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
 
Kardeşim gerçekten çok teşekkür ederim. Çok işime yaradı.
 
Geri
Üst