i have developed an outlook macro and want this macro to run automatically without any prompt or mail from the user whether the outlook is on or not.
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_SNAPSHOT = &H2C
Private Const VK_MENU = &H12
Private Const SW_SHOWMAXIMIZED = 3
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Const SW_MAXIMIZE = 3
Private Const SW_MINIMIZE = 6
Private Const SW_NORMAL = 1
Private Sub Application_Reminder(ByVal Item As Object)
If TypeName(Item) = "TaskItem" Then
Dim myItem As TaskItem
Set myItem = Item
If myItem.Subject = "run macro Mail_workbook_Outlook_1" Then
Call Mail_workbook_Outlook_1 '...your macro name here
End If
End If
End Sub
Sub Mail_workbook_Outlook_1()
ChDrive ("D:")
ChDir ("D:\Eclipse\Workspaces\struts\Sonar\src\report")
'Shell ("cmd.exe /S /K" & "java D:\Eclipse\Workspaces\struts\Sonar\src\reportOpenBrowser")
'Const exeCmd = "java OpenBrowser"
'Shell ("java OpenBrowser")
Dim sdkCommand As String
sdkCommand = "java Orange "
Shell ("cmd.exe /c" & sdkCommand)
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.To = "check"
.CC = ""
.BCC = ""
.Subject = "Orange "
.Body = "Hi all " _
& "PFB the status of Sonar report for Trunk"
.Attachments.Add ActiveWorkbook.FullName
'You can add other files also like this
.Attachments.Add ("d:\\Orange .jpg")
.HTMLBody = .HTMLBody & "<br>Orange REPORT:<br>" _
& "<br><img src='d:\\Orange .jpg'" & "width='900' height='600'><br>" _
& "Orange .<br>" _
& "google.com" _
& "<br>Regards,<br>Gaurav</font></span>"
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub