i used the below code to create a SNP file attach to an email and send to the specified address, this code will bypass the "a program is trying to send an email" security feature in Outlook
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.OpenReport "Emergency Energize", acViewNormal, , , acWindowNormal
Dim outfile As String
outfile = "C:\Emergency_Energize.SNP"
DoCmd.OutputTo acOutputReport, "Emergency Energize", acFormatSNP, outfile
Dim objol As New Outlook.Application
Dim objmail As MailItem
Set objol = New Outlook.Application
Set objmail = objol.CreateItem(olMailItem)
With objmail
.To = "" 'enter in here the email address
.CC = "" 'enter in here the email address
.Subject = "" ' & dname
.Body = "" & _
vbCrLf & "" & vbCrLf
.NoAging = True
.Attachments.Add "C:\Emergency_Energize.SNP" 'adds attachment to email
.Display
End With
Set objmail = Nothing
Set objol = Nothing
SendKeys "%{s}", True 'send the email without prompts
|