Does anyone know if you can send an email from Access using the stationary set in outlook.
I have a form that sends the email but it only opens a blank email, it would be great if it opened using our company stationary
Here is the code for the send button, it also adds an attachment to the email from info in the database also
- Private Sub cmdSendMail_Click()
-
-
'Provides the Send Mail automation
-
-
Dim oLook As Object
-
Dim oMail As Object
-
Dim olns As Outlook.NameSpace
-
-
-
Set oLook = CreateObject("Outlook.Application")
-
Set olns = oLook.GetNamespace("MAPI")
-
Set oMail = oLook.CreateItem(0)
-
-
With oMail
-
-
If IsNull(Me.LblUserName.Value) Then
-
MsgBox "You cannot send email to no-one!", vbCritical, "Email Sending Error"
-
Exit Sub
-
End If
-
-
.To = Me.LblUserName.Value
-
-
If IsNull(Me.EmailMessageBox.Value) Then
-
MsgBox "You did not enter any content in the Email Message Body. Sending has been aborted.", vbCritical
-
Me.EmailMessageBox.SetFocus
-
Exit Sub
-
End If
-
-
.Body = Me.EmailMessageBox.Value
-
-
-
If IsNull(Me.EmailSubject.Value) Then
-
MsgBox "Please provide a subject for this email", vbExclamation, "Empty Subject Field"
-
Exit Sub
-
End If
-
-
.Subject = Me.EmailSubject.Value
-
-
' Evaluate full filepath from link
-
-
LenFile = Len(Forms!Results.File.Value)
-
Forms!Results.filetxt.Value = Mid(Forms!Results.File.Value, 2, LenFile - 2)
-
-
.Attachments.Add Forms!Results.filetxt.Value
-
-
-
If Me.PreviewSender.Value = 2 Then
-
.Display
-
Else
-
.Send
-
MsgBox "Email sent successfully"
-
DoCmd.Close acForm, "Email Options"
-
End If
-
-
-
End With
-
Set oMail = Nothing
-
Set oLook = Nothing
-
-
Forms!Results.Command8.SetFocus
-
-
End Sub
Thanks