Connecting Tech Pros Worldwide Forums | Help | Site Map

email form using stationary

colinod's Avatar
Familiar Sight
 
Join Date: Nov 2007
Posts: 182
#1: Aug 15 '08
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

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdSendMail_Click()
  2.  
  3. 'Provides the Send Mail automation
  4.  
  5. Dim oLook As Object
  6. Dim oMail As Object
  7. Dim olns As Outlook.NameSpace
  8.  
  9.  
  10.     Set oLook = CreateObject("Outlook.Application")
  11.     Set olns = oLook.GetNamespace("MAPI")
  12.     Set oMail = oLook.CreateItem(0)
  13.  
  14.     With oMail
  15.  
  16.     If IsNull(Me.LblUserName.Value) Then
  17.     MsgBox "You cannot send email to no-one!", vbCritical, "Email Sending Error"
  18.     Exit Sub
  19.     End If
  20.  
  21.     .To = Me.LblUserName.Value
  22.  
  23.     If IsNull(Me.EmailMessageBox.Value) Then
  24.     MsgBox "You did not enter any content in the Email Message Body. Sending has been aborted.", vbCritical
  25.     Me.EmailMessageBox.SetFocus
  26.     Exit Sub
  27.     End If
  28.  
  29.     .Body = Me.EmailMessageBox.Value
  30.  
  31.  
  32.     If IsNull(Me.EmailSubject.Value) Then
  33.     MsgBox "Please provide a subject for this email", vbExclamation, "Empty Subject Field"
  34.     Exit Sub
  35.     End If
  36.  
  37.     .Subject = Me.EmailSubject.Value
  38.  
  39. '  Evaluate full filepath from link
  40.  
  41.     LenFile = Len(Forms!Results.File.Value)
  42.     Forms!Results.filetxt.Value = Mid(Forms!Results.File.Value, 2, LenFile - 2)
  43.  
  44.     .Attachments.Add Forms!Results.filetxt.Value
  45.  
  46.  
  47.     If Me.PreviewSender.Value = 2 Then
  48.     .Display
  49.     Else
  50.     .Send
  51.     MsgBox "Email sent successfully"
  52.     DoCmd.Close acForm, "Email Options"
  53.     End If
  54.  
  55.  
  56.     End With
  57.     Set oMail = Nothing
  58.     Set oLook = Nothing
  59.  
  60.     Forms!Results.Command8.SetFocus
  61.  
  62. End Sub
Thanks

Reply


Similar Microsoft Access / VBA bytes