I'm assigning an Outlook task via Excel. As I have not saved a copy of the task an alert shows saying that the task won't be saved and asking if I want to send it anyway.
I've been using Sendkeys (I know, it's not a good way). It's working on my computer but not on the computers of some of my colleagues.
Would it be possible to deactivate those alerts?
Here is my code:
Sub SendMail(dest As String, Echeance As String)
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Dim i As Integer
Dim nom As String
Dim compte As Integer
Dim myOlApp As Outlook.Application
Dim myItem As Outlook.TaskItem
Dim myDelegate As Outlook.Recipient
Set myOlApp = New Outlook.Application
For i = 1 To myOlApp.Session.Folders.Count
If myOlApp.Session.Folders.Item(i) = "_F_VTG-LBA ALCG-RAVEVAC" Then
compte = i
Exit For
End If
Next i
Set myItem = myOlApp.Session.Folders.Item(compte).Items.Add(olTaskItem)
myItem.Assign
Set myDelegate = myItem.Recipients.Add(dest)
myDelegate.Resolve
If myDelegate.Resolved Then
myItem.Subject = Task.titre
myItem.Body = Task.Mess
myItem.DueDate = Echeance
myItem.StartDate = Now
myItem.ReminderTime = True 'Rappel
myItem.Display
Application.DisplayAlerts = False
myItem.Send
'Or
Application.Wait (Now + TimeValue("0:00:03"))
Application.SendKeys "^~" 'presses send as a send key
Application.Wait (Now + TimeValue("0:00:03"))
SendKeys "TAB", True
SendKeys "{ENTER}", True
i = 0
End If
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
If you do not want the task in your own list then assign the normal way then delete.