Emailing Tasks in Access

CBragg

VB Dummy
Local time
Today, 20:35
Joined
Oct 21, 2002
Messages
89
I have a database set up in access which allows you to create tasks and send them to recipients using VB Code.

When sending the task it comes up with this Error Message

"The Task "Task Name" is stored as a file, not as an item in an Outlook folder, so the requested action could not be performed"

This is a short version of my code:

Private Sub Command2_Click()
On Error GoTo Err_Handler

Dim NameSpace As Object
Dim EmailSend As TaskItem 'for the task item add outlook reference
Dim EmailApp As Object

Set EmailApp = CreateObject("Outlook.Application") 'Outlook object
Set NameSpace = EmailApp.getNameSpace("MAPI")
Set EmailSend = EmailApp.CreateItem(3) ' CreateItem(3) Task Item

EmailSend.Subject = "Task Name" 'Task Subject

EmailSend.Body = "Call No: " & Me![RefNo]
EmailSend.Recipients.Add Me![Fixer]
EmailSend.Assign
EmailSend.Send

MsgBox "Message has been sent successfully"
Exit Sub
Err_Handler:
MsgBox Err.Description
End Sub

Any suggestions would be greatly appreciated on either how to get by this problem or what the actual error message is saying.
 
I don't think I'm good enough to solve your problem, but I'll show you a working code that does the same thing, and perhaps you will be able to see the error.:
Code:
Private Sub cmdSend_Click()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim MyDate As Date
Dim NameRef As String
Dim JobRef As String
Dim olkapps As Outlook.Application
Dim olknamespaces As Outlook.NameSpace
Dim objmailitems As Outlook.MailItem
Dim AttachRef As String
Dim SubjectRef As String
Dim Count As Integer
Dim stDocName As String
Dim ContactRef As String
Count = 0
Set db = CurrentDb
Set rst = db.OpenRecordset("qrySendMemo")

If rst.EOF = False Then
rst.MoveFirst
End If
Do Until rst.EOF = True
NameRef = rst.Fields("E-mail").Value
JobRef = rst.Fields("JobNumber").Value
ContactRef = IIf(IsNull(rst.Fields("Contact").Value), "Sir or Madam", rst.Fields("Contact").Value) 'null values?
SubjectRef = "Job number #" & rst.Fields("JobNumber").Value & " on the ISU job board"
Set olkapps = New Outlook.Application
Set olknamespaces = GetNamespace("MAPI")
Set objmailitems = olkapps.CreateItem(olMailItem)
With objmailitems
.To = NameRef
.ReplyRecipients.Add ("sfajobs@iastate.edu")
.Subject = SubjectRef
.Body = "Dear " & IIf(ContactRef = "", "Sir or Madam", ContactRef) & "," & txtBodyRef.Value & txtBodyRef2.Value
.Importance = olImportanceHigh
.Send

End With

Set objmailitems = Nothing
Set olknamespaces = Nothing
Set olkapps = Nothing

Count = Count + 1
rst.MoveNext

Loop

Set rst = Nothing
Set db = Nothing

I don't think anything is missing from there.
 
Thanks, for that but after hours of wasting time changing the code, it was simply that because i was working from local MS Access that it needed a local version of MS Outlook.

Thanks for your reply anyway!!
 
I hate it when you run into errors like that. Oh well, at least it's all set now.
 

Users who are viewing this thread

Back
Top Bottom