Olaya bir yerden başlamak için internetten bakarak şu kodu yazdım. Ama şu hatayı veriyor:
Run-time error '2501':
OutputTo eylemi iptal edildi.
Kod ise şöyle:
Private Sub Komut75_Click()
DoCmd.OutputTo acOutputReport, "BirSonrakiBakım Raporu", acFormatPDF, CurrentProject.path & "C:\BirSonrakiBakım Raporu.pdf", False, , , acExportQualityPrint
' + mail gönderme işlemi
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") = "hbulut.kar.backup@gmail.com"
Flds.Item(schema & "sendpassword") = "xxxxxxxxxxxxxx"
Flds.Item(schema & "smtpusessl") = 1
Flds.Update
With iMsg
.To = "[email protected]"
.From = "hbulut.kar.backup@gmail.com"
.Subject = "pdf gönder"
.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 Application.CurrentProject.path & "C:\BirSonrakiBakım Raporu.pdf" 'burda stfile adlı globale atadığımız rapor dosyasının yeri adı"
Set .Configuration = iConf
.Send
End With
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing
Kill (CurrentProject.path & "C:\BirSonrakiBakım Raporu.pdf")
End Sub