Sending email with MS Access. Third Party Permission Allowed.

I need to send some email notifications from an MS Access database.

  • There are no third-party dlls like Redemption.
  • Unable to disable Outlook security alerts
  • A PDF attachment will be added in the email.

I know that for this I need to use MAPI, but I can not find a way to do this using VBA.

Any help would be appreciated

Thanks,

Scott

+3
source share
3 answers

, CDO , SMTP-, , . Google , www.rondebruin.nl:

Sub CDO_Mail_Small_Text()
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
'    Dim Flds As Variant

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

'    iConf.Load -1    ' CDO Source Defaults
'    Set Flds = iConf.Fields
'    With Flds
'        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
'        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") _
'                       = "Fill in your SMTP server here"
'        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
'        .Update
'    End With

strbody = "Hi there" & vbNewLine & vbNewLine & _
          "This is line 1" & vbNewLine & _
          "This is line 2" & vbNewLine & _
          "This is line 3" & vbNewLine & _
          "This is line 4"

With iMsg
    Set .Configuration = iConf
    .To = "ron@debruin.nl"
    .CC = ""
    .BCC = ""
    .From = """Ron"" <ron@something.nl>"
    .Subject = "Important message"
    .TextBody = strbody
    .Send
End With

End Sub

.AddAttachment "C:\files\filename.pdf" iMsg.

+2

:

Dim strErrMsg As String 'For Error Handling
Dim olApp As New Outlook.Application
Dim olNameSpace As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim oleGrf As Object
Dim strFileName As String

Set olNameSpace = olApp.GetNamespace("MAPI")
Set olMail = olApp.CreateItem(olMailItem)
Set oleGrf = Me.OLEchart.Object
strFileName = "c:\temp\Graph.jpg"
oleGrf.Export FileName:=strFileName

With olMail
    .To = "someone@somewhere.com"
    .Subject = "Graph Info " & Format(Now(), "dd mmm yyyy  hh:mm")
    .Attachments.Add strFileName
    .ReadReceiptRequested = False
    .Send
End With
Kill strFileName

Tony Toews Microsoft Access

0
0
source

Source: https://habr.com/ru/post/1712776/


All Articles