David Williamson
asked on
cfmail an outlook task
Is anyone aware of a way to email someone an outlook task using CF, or for that matter, any language?
By the way, instantiating Outlook on the end-users machine will generate security warnings so you will want them to add your site into their trusted sites list.
Here is some sample code. Just do something like this:
Set objOL = CreateObject("Outlook.Appl ication")
Set myItem = objOL.CreateItem(3)
myItem.Assign
Set myDelegate = myItem.Recipients.Add("Pat Buchanan, George Bush")
myItem.Subject = "Slap around Mr. Kerry"
myItem.DueDate = #12/31/2004#
myItem.Send
You might have to debug the above code - have not tested it.
Also, here is some code to determine if Outlook is already running before you try to start it up. Otherwise you MIGHT get "can't create object errors"
Function OpenOL(Optional ProfileName) As Outlook.Application
Dim objOL As Outlook.Application
On Error Resume Next
Set objOL = GetObject(, "Outlook.Application")
If objOL Is Nothing Then
Set objOL = CreateObject("Outlook.Appl ication")
objOL.Session.Logon ProfileName, , False, True
End If
Set OpenOL = objOL
Set objOL = Nothing
End Function
Here is some sample code. Just do something like this:
Set objOL = CreateObject("Outlook.Appl
Set myItem = objOL.CreateItem(3)
myItem.Assign
Set myDelegate = myItem.Recipients.Add("Pat
myItem.Subject = "Slap around Mr. Kerry"
myItem.DueDate = #12/31/2004#
myItem.Send
You might have to debug the above code - have not tested it.
Also, here is some code to determine if Outlook is already running before you try to start it up. Otherwise you MIGHT get "can't create object errors"
Function OpenOL(Optional ProfileName) As Outlook.Application
Dim objOL As Outlook.Application
On Error Resume Next
Set objOL = GetObject(, "Outlook.Application")
If objOL Is Nothing Then
Set objOL = CreateObject("Outlook.Appl
objOL.Session.Logon ProfileName, , False, True
End If
Set OpenOL = objOL
Set objOL = Nothing
End Function
ASKER
Most of this is unfamiliar to me, and therefore may be beyond me. I don't have any VB experience, just CF, HTML, CSS, and JS.
I have yet to find a way to do it using server side. Outlook just doesn't support it. I could send you a 100% working snippit that creates EMAILS on the client side using Outlook. Would that help?
-Pat
-Pat
ASKER
sure
I'm at work where I don't have the code - it's at home. Can I send it to you later?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
so how do I implement/test this? I have never used VBScript. Can it be used or called in a web page?
To test it, just create an basic HTML page, and paste the above code into it.
Now you need something to call the function. You can make it "auto-run" by just calling the function right after you declare it, by adding this line:
EmailSample
directly below the "end sub" line, but still inside the <script> tags.
If you wanted to call it based on a button click, you could instead place this code in the <body> of your page:
<button onclick="EmailSample">Send Email</button>
There are a bunch of VBScript / JavaScript tutorials on the web that will get you up to speed in 1 day (it's pretty simple in some ways). As you delve deeper into "outside of the box" web programming like automation (what we are doing above) learning VBScript/JavaScript is essential.
Thanks!
-Pat
Now you need something to call the function. You can make it "auto-run" by just calling the function right after you declare it, by adding this line:
EmailSample
directly below the "end sub" line, but still inside the <script> tags.
If you wanted to call it based on a button click, you could instead place this code in the <body> of your page:
<button onclick="EmailSample">Send
There are a bunch of VBScript / JavaScript tutorials on the web that will get you up to speed in 1 day (it's pretty simple in some ways). As you delve deeper into "outside of the box" web programming like automation (what we are doing above) learning VBScript/JavaScript is essential.
Thanks!
-Pat
ASKER
I use JS all the time, so if its similar to VBS, then I should be just fine.
Yep - it's pretty close. Just a few different annoyances, like:
EmailSample
instead of
EmailSample()
like in JS.
You'll like it in some ways and hate it in others. :) I think VBScript has much better support for date formats, for example.
Hope that helped you!
-Pat
EmailSample
instead of
EmailSample()
like in JS.
You'll like it in some ways and hate it in others. :) I think VBScript has much better support for date formats, for example.
Hope that helped you!
-Pat
I have some samples of how to do that for emails but not tasks. But it may give you a head start. Interested?