![]() |
Excel dosyasını mail gönderme. - Baskı Önizleme +- AccessTr.neT (https://accesstr.net) +-- Forum: Microsoft Access (https://accesstr.net/forum-microsoft-access.html) +--- Forum: Access Cevaplanmış Soruları (https://accesstr.net/forum-access-cevaplanmis-sorulari.html) +--- Konu Başlığı: Excel dosyasını mail gönderme. (/konu-excel-dosyasini-mail-gonderme.html) |
Excel dosyasını mail gönderme. - besst - 08/06/2009 Merhaba Access vb'da TransferSpreadsheet ile 2 adet çalışma sayfası içeren Excel dosyası oluşturuyorum ve devamında oluşturduğum bu Excel dosyasını varsayılan mail programı ile göndermek istiyorum. Bunu nasıl yapabilirim, yardımlarınız için şimdiden teşekkürler Cvp: Excel dosyasını mail gönderme. - esrefigit - 08/06/2009 bunu globale Dim stFile As String bunu excele dönüştürme düğmesine stFile = CurrentProject.Path & "\" & dosyaadi & ".xls" Kill stFile DoCmd.TransferSpreadsheet acExport, , "sorguadi", stFile, False, durumum bundan sonrada referanslardan microsoft cdo referansını açın yada seçin ondan sonrada gönder düğmesine Dim iMsg, iConf, Flds, schema Set iMsg = CreateObject("CDO.Message") Set iConf = CreateObject("CDO.Configuration") Set Flds = iConf.Fields schema = "http://schemas.microsoft.com/cdo/configuration/" Flds.Item(schema & "sendusing") = 2 Flds.Item(schema & "smtpserver") = "smtp.gmail.com" Flds.Item(schema & "smtpserverport") = 465 Flds.Item(schema & "smtpauthenticate") = 1 Flds.Item(schema & "sendusername") = "gmailadresim" Flds.Item(schema & "sendpassword") = "gmailşifrem" Flds.Item(schema & "smtpusessl") = 1 Flds.Update With iMsg .To = me.metinkutusugidecekkişimailadresi .From = me.gönderenkişiadıyanibenmetinkutusu .Subject = "konuumuz excelle gönderinimi" .HTMLBody = "evettt gönderdik gitti aldınızsa bana cepten ulaşın" .Sender = "ben" .Organization = "yineben" .ReplyTo = "yanlışkişiyegitti ise geri gelecek adres" .AddAttachment stFile 'burda stfile adlı globale atadığımız Excel dosyasının yeri adı Set .Configuration = iConf .Send End With Set iMsg = Nothing Set iConf = Nothing Set Flds = Nothing hepsi bu yalnız gmailden pop3 desteğini aktifleştirmen gerekiyor ozaman hiç bir mail programına gerek kalmadan Excel dosyalarını ek olarak gönderdiirsin Cvp: Excel dosyasını mail gönderme. - besst - 08/06/2009 Gönderdiğiniz kodlar gmail ile gönderim için sanırım , fakat benim bilgisayarımdaki mevcut varsayılan mail programı (winmail)pop3 hesabım ile gönderim yapmam gerekiyor. Mesela şu an yapmaya çalıştığım işlemi Microsoft Outlook ile uygulayabiliyorum örnek kodlar aşağıda ; Fakat winmail yada outlook express ile yapamıyorum. Bir çok araştırma yaptım sonuç olarak bir ipucuna rastlayamadım, sanmıyorum ama ya bu işlem çok kolay hep gözden kaçıyor ya da imkansız ! Private Sub gonder_Click() DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "tablo1", Application.CurrentProject.Path & "\ornek.xls", sayfa1 DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel8, "tablo2", Application.CurrentProject.Path & "\ornek.xls", sayfa2 Dim appOutlook As New Outlook.Application Set msg = appOutlook.CreateItem(olMailItem) With msg .To = "mail@adresim" .Subject = "strSubject" .Body = "strBody" .Attachments.Add Application.CurrentProject.Path & "\ornek.xls" .Display End With End Sub Cvp: Excel dosyasını mail gönderme. - nihatkr - 08/06/2009 Sub Excelden_Mail() Dim objOL As Object Dim objMail As Object Dim objwShell As Object Dim strEmail As String strEmail = "[email protected]" On Error GoTo temizle Set objwShell = CreateObject("wscript.shell") objwShell.Run ("""C:\Program Files\microsoft office\office12\OUTLOOK.exe"" -activate") Set objOL = CreateObject("Outlook.Application") Set objMail = objOL.CreateItem(0) With objMail .To = strEmail .Subject = [Sayfa1!h12] .Body = "DENEME YAPIYORUZ BAKIN TARİHİ YAZDI" MsgBox "TAMAMA BASINIZ", vbInformation, "NİHATKR TARAFINDAN YAPILMIŞTIR" .send End With objwShell.Run ("""C:\Program Files\microsoft office\office12\OUTLOOK.exe"""" -stop") temizle: Set objMail = Nothing Set objOL = Nothing Set objwShell = Nothing On Error GoTo 0 End Sub kodu yazın bir düğmeye atayın. Aktif sayfadaki tüm verileri mail atma. Sub Mail_ActiveSheet() 'Working in 97-2007 Dim FileExtStr As String Dim FileFormatNum As Long Dim Sourcewb As Workbook Dim Destwb As Workbook Dim TempFilePath As String Dim TempFileName As String With Application .ScreenUpdating = False .EnableEvents = False End With Set Sourcewb = ActiveWorkbook 'Copy the sheet to a new workbook ActiveSheet.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 'We exit the sub when your answer is NO in the security dialog that you only 'see when you copy a sheet from a xlsm file with macro's disabled. If Sourcewb.Name = .Name Then With Application .ScreenUpdating = True .EnableEvents = True End With MsgBox "Your answer is NO in the security dialog" Exit Sub Else 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 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 = "Deneme " & " " & Format(Now, "dd-mmm-yy h-mm-ss") With Destwb .SaveAs TempFilePath & TempFileName & FileExtStr, FileFormat:=FileFormatNum On Error Resume Next .SendMail "", _ "Otomatik Mail Gönderimi" On Error GoTo 0 .Close SaveChanges:=False End With 'Delete the file you have send Kill TempFilePath & TempFileName & FileExtStr With Application .ScreenUpdating = True .EnableEvents = True End With End Sub Cvp: Excel dosyasını mail gönderme. - besst - 09/06/2009 Sayın esrefigit ve Sayın Nihatkr Verdiğiniz bilgiler ve ilginiz için çok teşekkürler fakat ne yazıkki benim sorunumu bu yöntemler çözmedi. outlook ve gmail (yada diğer ss) ile gönderim yapabiliyorum. Fakat benim ihtiyacım olan gönderim şekli outlook express yada vistanın varsayılan mail gönderim programı olan winmail. Yardımlarınız için tekrar teşekkürler Saygılar Cvp: Excel dosyasını mail gönderme. - nihatkr - 09/06/2009 Kodu yazmıştım ama sildim. siz eniyisi eörnek ekleyin. Biz sizin nasıl birşey istedğinizi tam anlayalım. Ona göre de çözüm üretelim. böyle taşıma suyla değirmen oluyor |