UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> How To Create Task+reminder For VBA Generated Email?, Office 2013    
 
   
PhilS
post Jun 10 2017, 12:38 PM
Post#1



Posts: 362
Joined: 26-May 15
From: The middle of Germany


I was doing some research on how to create a Task+Reminder for an VBA-generated Outlook email.
I use code like this (simplyfied for brevity)
CODE

    Set myOutlApp = New Outlook.Application
    Set myMail = myOutlApp.CreateItem(olMailItem)
    With myMail
        .To = "'someone@somewhere.invalid'"
        .Subject = "Here is an email sent by Outlook-Automation"
        .Send
    End With

Now it want to create a Task and Reminder for the sender of this email. And, of course I want to do it in VBA-Code.

If found a solution by getting a reference to the SentItems-Folder, handle its ItemAdd-Event, and add the Task/Reminder in that event procedure. (All details: Send Outlook Emails with attached Flag and Reminder in VBA)
This works, but to me it seems to be insanely complicated for something that is so simple when sending an email manually.

So do you know any alternative to create a Task+Reminder automatically for a particular VBA generated email?
This post has been edited by PhilS: Jun 10 2017, 12:39 PM

--------------------
The shocking revelation about digital signatures for accdb files.
Go to the top of the page
 
cheekybuddha
post Jun 10 2017, 03:25 PM
Post#2


UtterAccess VIP
Posts: 9,082
Joined: 6-December 03
From: Telegraph Hill


Hmmm.... it looks quite simple really.

Save the class module, and the also the property in a standard module.

Then you just add one line to your email code:
CODE
    Set myOutlApp = New Outlook.Application
    Set myMail = myOutlApp.CreateItem(olMailItem)
    With myMail
        .To = "'someone@somewhere.invalid'"
        .Subject = "Here is an email sent by Outlook-Automation"
        EmailFollowupHandler.RegisterMailForFollowup myMail, DateAdd("d", 2, Date)  ' <-- Set date for follow-up
        .Send
    End With


The use of the class module seems to be to abstract the way you need to add a user-defined property to the email.

The property just returns an instance of the class, or sets an instance if one doesn't exist already.

dontknow.gif

d

--------------------


Regards,

David Marten
Go to the top of the page
 
PhilS
post Jun 12 2017, 01:17 AM
Post#3



Posts: 362
Joined: 26-May 15
From: The middle of Germany


Maybe the wording of my question was not entirely clear. The linked article and the suggested solution is my own writing and I found the solution not by googling on the net, but by looking at the Outlook classes, coding and testing.

QUOTE
it looks quite simple really.

David, thank you for the compliment! It was my goal to hide the complexity and make this functionality available with an easy to use interface.

My actual question is: Does the inner implementation have to be this complicated?
Isn't there an easier way to achieve the same result without the hassle of an With-Events-Reference to the Outlook folder and the event procedure for ItemAdd?

--------------------
The shocking revelation about digital signatures for accdb files.
Go to the top of the page
 
PhilS
post Jun 12 2017, 01:17 AM
Post#4



Posts: 362
Joined: 26-May 15
From: The middle of Germany


[Delete this please; double click on submit caused double post]
This post has been edited by PhilS: Jun 12 2017, 01:18 AM

--------------------
The shocking revelation about digital signatures for accdb files.
Go to the top of the page
 
cheekybuddha
post Jun 12 2017, 06:56 AM
Post#5


UtterAccess VIP
Posts: 9,082
Joined: 6-December 03
From: Telegraph Hill


blush.gif

Hahahaha! rotflmao.gif

I'm sorry I failed to realise that it was your code (especially as I should have known it's your site!)

I did think it was strange, Phil, that you would consider adding a couple of modules and a line of code to be 'insanely complicated'!!!

OK, perhaps it makes more sense if you were the one who had to work out how to write those modules!

Now that I have had enough coffee to understand you post correctly coffee1.gif , then Yes, I agree: Outlook programming seems to be way more complex than it needs to be.

Sometimes I wonder whether it's due to trying to make it more secure by making it virtually un-programmable!

More likely, it's an attempt to keep down the amount of the program it loads in to RAM by not having the properties available unless they are created explicitly.

However, at least there is a mechanism to sync the Outlook events in to Access.

Anyway, kudos again on a fine piece of code!

thumbup.gif hat_tip.gif

d

--------------------


Regards,

David Marten
Go to the top of the page
 


Custom Search
RSSSearch   Top   Lo-Fi    20th September 2017 - 06:14 AM