Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Email From Access add Priority

Posted on 2010-09-09
8
Medium Priority
?
393 Views
Last Modified: 2012-05-10
Dear Experts,

I am looking to add in a "High Priority" to an Email generated from Access.  I know there are 2 methods of creating the email - I would like to adapt this piece of code ...

DoCmd.SendObject acSendNoObject, , , Me.email

Rather than the full create outlook object etc (code attached) as I really don't want to have to download a bolt on program such as YesClick Pro to bypass outlook's security
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
 
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application", localhost)
'Set objOutlook = Outlook.Application
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
 
    With objOutlookMsg
        ' Add the To recipient(s) to the message. Substitute
        ' your names here.
        Set objOutlookRecip = .Recipients.Add("xxx@hotmail.com")   '<--Recipient's name or email address
 
        objOutlookRecip.Type = olTo
        ' Add the CC recipient(s) to the message.
        'Set objOutlookRecip = .Recipients.Add("CC Recipient Name")
        'objOutlookRecip.Type = olCC
        ' Set the Subject, Body, and Importance of the message.
        .Subject = "Blah Blah Blah"      '<--Subject
        .Body = "Dear Tom" & vbCr & vbCr
        '<--Email Body text.
 
        .Importance = olImportanceHigh  'High importance
        'Add attachments to the message.
        'Set objOutlookAttach = .Attachments.Add("C:\Earth.jpg")             '<-- Add as many attachments as you need here.
        'Set objOutlookAttach = .Attachments.Add("C:\TextFile.txt")
        
        ' Resolve each Recipient's name.
        For Each objOutlookRecip In .Recipients
            If Not objOutlookRecip.Resolve Then
                objOutlookMsg.Display
            End If
        Next
        
        'Send email without viewing it.
        '.Send
        
        'Dispay email before sending.
        .Display
    
    End With
 
'Cleanup Code
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
End Sub

Open in new window

0
Comment
Question by:correlate
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 33638376
You cannot do this directly.

With SendObject, the closest you get is:

DoCmd.SendObject ObjectType:=acSendNoObject, To:=Me.Email, Subject:="Subject, _
    MessageText:="Blah", EditMessage:=True

That brings up the message in the editor window for your installed email program, and from there you can add high priority.

   
0
 

Author Comment

by:correlate
ID: 33638529
Hi,

Thanks for this, sadly its what I expected, would using a template help? (never used them before so I'm clutching at straws here)
0
 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 33638598
Good question!

I'm not sure.  Perhaps you should click 'request attention' and ask the Mods to add the Outlook zone to this question.
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
LVL 31

Accepted Solution

by:
Helen Feddema earned 2000 total points
ID: 33639031
I think you will need to use Automation code, since SendObject doesn't let you work with all the properties of the email message.  You can download the Redemption Library from www.dimastr.com, and modify the code to use Redemption objects, to avoid the Object Model Guardian popups:
'Redemption objects and corresponding Outlook objects must
   'be declared as Object type
   Dim omsg As Object
   Dim msg As Object
   
      'Create new mail message and send it now
      Call OpenOutlook
      Set omsg = gappOutlook.CreateItem(olMailItem)
      Set msg = New Redemption.SafeMailItem
      msg.Item = omsg
      
      With msg
         .To = strToEMail
         .Subject = strMessageSubject
         .Body = strBody
         .Send
      End With
      
      'Note:  Messages created with Redemption Library objects
      'are created in the Drafts folder instead of the Outbox,
      'but they will be sent as if from the Outbox.

Open in new window

0
 
LVL 46

Expert Comment

by:tbsgadi
ID: 33659974
You need to use Automation not the SendObject.

To solve the Outlook Security popups, you can use Advanced Security for Outlook
http://www.mapilab.com/outlook/security/

Gary

0
 

Author Closing Comment

by:correlate
ID: 33660783
Hi,

Many thanks for this - sorry it took some time to reply, took a while to get my head around this - but it works
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question