Emailing without email program opening

Crash1hd

Registered CyberGeek
Local time
Today, 02:49
Joined
Jan 11, 2004
Messages
143
I am useing the following code to send email reports and I was wondering if there was a way since it knows how the email is going to that it would just send the email without opening outlook and the user having to hit send! :confused:

Code:
Private Sub Email_Helpdesk_Report_Click()
On Error GoTo Err_Email_Helpdesk_Report_Click
    
    Dim strText As String
    Dim SubjectLine As String
    Dim EmailAddress As String
    Dim Msg, Style, Title, Response
    Dim Capita As String
    Dim stDocName As String
    
    stDocName = "Mandatory_Helpdesk_Report"

EmailAddress = "email@email.ca"

Msg = "Do you want to email this to " & EmailAddress & "?"
Style = vbYesNo + vbDefaultButton2
Title = "Email Confirmation"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then

SubjectLine = "Help Desk Review"

    'DoCmd.SendObject acReport, stDocName
    DoCmd.SendObject acReport, stDocName, "RichTextFormat(*.rtf)", EmailAddress, , , SubjectLine, _
"Please log this call and return details to sender." & vbCrLf & vbCrLf & "Internal Reference: ", True

'Err_cmdEmailrptAcademyReport_Click:
'If Err.Number = 94 Then
'MsgBox "Data is incorrect or missing"
'End If
End If

Exit_Email_Helpdesk_Report_Click:
    Exit Sub

Err_Email_Helpdesk_Report_Click:
    MsgBox Err.Description
    Resume Exit_Email_Helpdesk_Report_Click
    
End Sub
 
Hope This Helps

DoCmd.SendObject acReport, stDocName, "RichTextFormat(*.rtf)", EmailAddress, , , SubjectLine, _
"Please log this call and return details to sender." & vbCrLf & vbCrLf & "Internal Reference: ", True
At the end of this line of code you have the word "True"
If you look up the syntax, this represents whether or not you want to "Edit the message".
If you change this to "False", the message will go right out without involving the sender.
The other issue is "Outlook".
If the sender is using a recent version of Outlook with recent patches, he will get a security message that "Another application is trying to access your email program. Do you want to allow this?"
 
send via smtp

I am using this code to send directly to my smtp server. You may want to try this.

Private Sub send_mail_smtp_Click()

Dim mail
Dim config
Dim fields
Dim stremail As String

Set mail = CreateObject("CDO.Message")
Set config = CreateObject("CDO.Configuration")
Set fields = config.fields

stremail = _
" Please review the following log at your earliest convenience" & vbCrLf & _
" " & vbCrLf & _
" " & "ASC Log Number: " & Me.Log_Number & vbCrLf & _
" " & "Date and Time: " & Me.Date & vbCrLf & _
" " & "Priority: " & Me.Priority & vbCrLf & _
" " & "Request Type: " & Me.Request_Type & vbCrLf & _
" " & "Employee: " & Me.Employee & vbCrLf & _
" " & "Program Name: " & Me.Program_Name & vbCrLf & _
" " & "Short Description: " & Me.Short_Description & vbCrLf & _
" " & "Long Description: " & Me.Long_Description & vbCrLf



With fields
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 ' SMTP SERVER
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "255.255.255.255" ' IP OF SERVER
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
.Update
End With

Set mail.Configuration = config

With mail
.From = "email address"
.To = "email address"
.CC = strCC
.Subject = "string"
.TextBody = stremail
.Send
End With

Set mail = Nothing
Set fields = Nothing
Set config = Nothing

MsgBox "Your log has been sent! Please write down your log number for future reference." & vbCrLf & _
" " & vbCrLf & _
"ASC Log Number: " & Me.ASC_Log_Number & vbCrLf



End Sub
 

Users who are viewing this thread

Back
Top Bottom