Önce ek olarak kaydedilen dosyayı dizine aktarmanız gerekli. Kodun tamamı aşağıdaki gibi olmalı.
'Dim C As Integer'
'C = MsgBox("Gözetim memurlarına iletiyorsun geri dönüş yok emin misin?", vbYesNo + vbQuestion + vbDefaultButton1, "Sharp Eye") '
'If C = vbNo Then'
'DoCmd.RunCommand acCmdUndo'
'End If'
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Dim GDosyaAdi As String
Dim rsKayit As DAO.Recordset2
Dim GEk
Set rsKayit = Me.Recordset
Set GEk = rsKayit.Fields("EK").Value
GDosyaAdi = Environ("Temp") & "\" & GEk.Fields("FileName")
If Len(Dir(GDosyaAdi)) > 0 Then
Kill GDosyaAdi
End If
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook
.to = Me.Email_Address
.Subject = Me.GEMİ & SEFER
.HTMLBody = Me.mess_text
GEk.Fields("FileData").SaveToFile Environ("Temp")
.Attachments.Add GDosyaAdi
'.DeleteAfterSubmit = True 'This would let Outlook send th note without storing it in your sent bin
.Send
End With
DoCmd.Close
'MsgBox MailOutLook.Body
Exit Sub
email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message is: " & err.Description
Resume Error_out
Error_out:
Kodun stabil çalışması için önce "Microsoft Outlook XX.0 Object Library" referansını eklemeniz gerekli.
Koddaki
Set rsKayit = Me.Recordset
Set GEk = rsKayit.Fields("EK").Value
GDosyaAdi = Environ("Temp") & "\" & GEk.Fields("FileName")
GEk.Fields("FileData").SaveToFile Environ("Temp")
Kısmı, ek alanındaki dosyayı bilgisayarınızdaki Temp dizinine kaydeder. Maile ek olarak bu kaydedilen dosya kullanılır.