Link to home
Start Free TrialLog in
Avatar of Tom Crowfoot
Tom CrowfootFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Email From Access add Priority

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

Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

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.

   
Avatar of Tom Crowfoot

ASKER

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)
Good question!

I'm not sure.  Perhaps you should click 'request attention' and ask the Mods to add the Outlook zone to this question.
ASKER CERTIFIED SOLUTION
Avatar of Helen Feddema
Helen Feddema
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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

Hi,

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