• DİKKAT

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

Sayfayı e-maıl olarak gönderme

sinnernekolens

Altın Üye
Katılım
23 Temmuz 2009
Mesajlar
310
Excel Vers. ve Dili
Ofis 2019 - Türkçe 64bit
Değerli üstadlar; aşağıdaki kod ile pdf butonuna tıkladığım zaman agent - pda sayfasını masa üstüne pdf dosyası olarak kayıt ediyorum.
Sizden isteğim aynı şekilde agent - pda sayfasını e-maıl butonu ekleyip tıkladığım zaman outlook a eklemesini istiyorum yardımlarınızı rica ederim.


Sub Metinkutusu2_Tıklat()
yol = ThisWorkbook.Path
isim = Format(Range("G5").Value, "yyyy-mm-dd-hh-mm") & " - " & Format(Now, "dd-mm-yy") & " - PDA"

'Sheets("AGENT - PDA").Select
Sheets("AGENT - PDA").Range("A1:T61").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
yol & "/" & isim & ".pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True

End Sub
 
Son düzenleme:
Merhaba,

Neden mesajınızı BÜYÜK HARFLE yazdınız...

Forum kurallarını okumanızı rica ediyorum. İmzamdan ulaşabilirsiniz...
 
Pardon inanın yoğunlukdan hiç fark etmedim gerekli düzeltmeyi yaptım. yardımlarınızı rica ediyorum.
 
Aşağıdaki kodu deneyiniz.

Kod:
Sub Pdf_Mail_ActiveSheet()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim Yol As String, Dosya_Adi As String

    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With

    Yol = ThisWorkbook.Path
    Dosya_Adi = Yol & "\" & Format(Range("G5").Value, "yyyy-mm-dd-hh-mm") & " - " & Format(Now, "dd-mm-yy") & " - PDA.pdf"
    
    Sheets("AGENT - PDA").Range("A1:T61").ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:=Dosya_Adi, Quality:=xlQualityStandard, IncludeDocProperties:=True
    
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
        .To = "deneme@gmail.com"
        .CC = ""
        .BCC = ""
        .Subject = "Günlük Rapor"
        .Body = "Merhaba," & Chr(10) & Chr(10) & "Şirketimize ait günlük rapor ektedir." & Chr(10) & Chr(10) & "Bilgilerinize."
        .Attachments.Add Dosya_Adi
        .Send
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing

    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With

    MsgBox "İşleminiz tamamlanmıştır.", vbInformation
End Sub
 
Teşekkür ederim eline sağlık; email atmadan sadece outlook a eklemesini nasil yapabilirim ayrıca bir kopyasını masa üstüne kaydediyor bunu kaldırabilirmiyiz.
 
Merhaba,

Bu kodu uyguladığınız dosyanız sisteminizde nerede ise oraya sayfayı PDF olarak kayıt eder. Eğer dosya silinsin diyorsanız.

On Error GoTo 0 satırını bulun ve hemen altına alttaki satırı ekleyin.

Kod:
Kill Dosya_Adi


Dosyayı mail atmadan sadece outlooka ekleme yapmak için kod içindeki .Send satırını .Display olarak değiştirin.
 
Çok güzel oldu allah razı olsun son birşey isteyebilirmiyim ayni işlemi pdf değilde excel sayfası olarak yapabilirmiyim ben biraz uğraştım ama yapamadım. yaptığım işlem aşağıda.

Kod:
Sub Düğme33_Tıklat()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim Yol As String, Dosya_Adi As String

    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With

    Yol = ThisWorkbook.Path
    Dosya_Adi = Yol & "\" & Format(Range("D12").Value, "yyyy-mm-dd-hh-mm") & " - " & Format(Now, "dd-mm-yy") & " - ARF-02"
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False

    Sheets("ARF-02").Copy
    If Val(Application.Version) > 11 Then
    ActiveWorkbook.SaveAs Filename:=Yol & "\" & ad & ".xls", FileFormat:=xlExcel8
    Else
    ActiveWorkbook.SaveAs Filename:=Yol & "\" & ad & ".xls"
    End If
    ActiveWorkbook.Close True
    Application.ScreenUpdating = True

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
        .To = ""
        .CC = ""
        .BCC = ""
        .Subject = "Günlük Rapor"
        .Body = "Merhaba," & Chr(10) & Chr(10) & "Şirketimize ait günlük rapor ektedir." & Chr(10) & Chr(10) & "Bilgilerinize."
        .Attachments.Add Dosya_Adi
        .Display
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing

    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With
End Sub
 
Aşağıdaki kodu deneyiniz.

Kod:
Sub Mail_ActiveSheet()
'Working in Excel 2000-2013
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
    Dim FileExtStr As String
    Dim FileFormatNum As Long
    Dim Sourcewb As Workbook
    Dim Destwb As Workbook
    Dim TempFilePath As String
    Dim TempFileName As String
    Dim OutApp As Object
    Dim OutMail As Object

    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With

    Set Sourcewb = ActiveWorkbook

    'Copy the ActiveSheet to a new workbook
    Sheets("AGENT - PDA").Copy
    Set Destwb = ActiveWorkbook

    'Determine the Excel version and file extension/format
    With Destwb
        If Val(Application.Version) < 12 Then
            'You use Excel 97-2003
            FileExtStr = ".xls": FileFormatNum = -4143
        Else
            'You use Excel 2007-2013
            Select Case Sourcewb.FileFormat
            Case 51: FileExtStr = ".xlsx": FileFormatNum = 51
            Case 52:
                If .HasVBProject Then
                    FileExtStr = ".xlsm": FileFormatNum = 52
                Else
                    FileExtStr = ".xlsx": FileFormatNum = 51
                End If
            Case 56: FileExtStr = ".xls": FileFormatNum = 56
            Case Else: FileExtStr = ".xlsb": FileFormatNum = 50
            End Select
        End If
    End With

    '    'Change all cells in the worksheet to values if you want
    '    With Destwb.Sheets(1).UsedRange
    '        .Cells.Copy
    '        .Cells.PasteSpecial xlPasteValues
    '        .Cells(1).Select
    '    End With
    '    Application.CutCopyMode = False

    'Save the new workbook/Mail it/Delete it
    TempFilePath = Environ$("temp") & "\"
    TempFileName = Format(Range("G5").Value, "yyyy-mm-dd-hh-mm") & " - " & Format(Now, "dd-mm-yy") & " - PDA"

    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    With Destwb
        .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum
        On Error Resume Next
        With OutMail
            .to = "deneme@gmail.com"
            .CC = ""
            .BCC = ""
            .Subject = "Günlük Rapor"
            .Body = "Merhaba," & Chr(10) & Chr(10) & "Şirketimize ait günlük rapor ektedir." & Chr(10) & Chr(10) & "Bilgilerinize."
            .Attachments.Add Destwb.FullName
            .Display
        End With
        On Error GoTo 0
        .Close savechanges:=False
    End With

    'Delete the file you have send
    Kill TempFilePath & TempFileName & FileExtStr

    Set OutMail = Nothing
    Set OutApp = Nothing

    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With

    MsgBox "İşleminiz tamamlanmıştır.", vbInformation
End Sub
 
Bu kod ile butona tıkladığım zaman sayfa1'i pdf ye cevirip emaile ekliyor. sizden isteğim Sayfa2'yi de pdf ye çevirip ayrı dosya olarak aynı email içine eklemesi mümkünmüdür?

Kod:
Sub Metinkutusu2_Tıklat()
    Dim OutApp As Object
    Dim OutMail As Object
    Dim Yol As String, Dosya_Adi As String

    With Application
        .ScreenUpdating = False
        .EnableEvents = False
    End With

    Yol = ThisWorkbook.Path
    Dosya_Adi = Yol & "\" & Format(Range("G5").Value, "yyyy-mm-dd-hh-mm") & " - " & Format(Now, "dd-mm-yy hh.mm") & " - PDA.pdf"
    
    Sheets("Sayfa1").Range("A1:T61").ExportAsFixedFormat Type:=xlTypePDF, _
    Filename:=Dosya_Adi, Quality:=xlQualityStandard, IncludeDocProperties:=True
    
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    On Error Resume Next
    With OutMail
        .To = ""
        .CC = ""
        .BCC = ""
        .Subject = Format(Range("G5").Value, "yyyy-mm-dd-hh-mm") & " - " & Format(Now, "dd-mm-yy hh.mm") & " - PDA"
        .Body = "İyi günler," & Chr(10) & Chr(10) & "Proforma ekte sunulmuştur." & Chr(10) & Chr(10) & "İyi çalışmalar."
        .Attachments.Add Dosya_Adi
        .Display
    End With
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing

    With Application
        .ScreenUpdating = True
        .EnableEvents = True
    End With

End Sub
 
Geri
Üst