- Joined
- Apr 8, 2009
- Messages
- 2
- Reaction score
- 0
I have written below code for hyperlink but i want a code that will ALSO put email in and send as outlook automatically
Sub CreateHperlinkMail()
Dim olApp As Object
Dim Msg As Object
Dim bWeStartedOutlook As Boolean
Application.ScreenUpdating = False
Application.StatusBar = "Craeting email"
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If Err.Number <> 0 Then
Set olApp = CreateObject("Outlook.Application")
bWeStartedOutlook = True
End If
On Error GoTo 0
If olApp Is Nothing Then
Application.StatusBar = False
MsgBox "Cannot start Outlook. Make sure Outlook is installed and can be run manually from this computer.", vbInformation
GoTo ExitProc
End If
Set Msg = olApp.CreateItem(0)
With Msg
.Subject = "Testing"
.HTMLBody = "<span style=""font-family : verdana;font-size : 12pt""><p>Hello,</p>" & _
"<p>Below is a link to the stress test file.</p>" & _
"<p><a href=" & Chr(34) & "N:\Sup\Test\Test" & " " & Format(Now, "dd-mmm-yy") & ".xls" & Chr(34) & ">output</a></p>" & _
"<p>Regards,<br />Regards</p></span>" & "<br />"
.Display
End With
ExitProc:
Set Msg = Nothing
' we need to call the Quit method, to quit Outlook if we actually started it ourselves
If bWeStartedOutlook Then olApp.Quit
Set olApp = Nothing
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub
Sub CreateHperlinkMail()
Dim olApp As Object
Dim Msg As Object
Dim bWeStartedOutlook As Boolean
Application.ScreenUpdating = False
Application.StatusBar = "Craeting email"
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If Err.Number <> 0 Then
Set olApp = CreateObject("Outlook.Application")
bWeStartedOutlook = True
End If
On Error GoTo 0
If olApp Is Nothing Then
Application.StatusBar = False
MsgBox "Cannot start Outlook. Make sure Outlook is installed and can be run manually from this computer.", vbInformation
GoTo ExitProc
End If
Set Msg = olApp.CreateItem(0)
With Msg
.Subject = "Testing"
.HTMLBody = "<span style=""font-family : verdana;font-size : 12pt""><p>Hello,</p>" & _
"<p>Below is a link to the stress test file.</p>" & _
"<p><a href=" & Chr(34) & "N:\Sup\Test\Test" & " " & Format(Now, "dd-mmm-yy") & ".xls" & Chr(34) & ">output</a></p>" & _
"<p>Regards,<br />Regards</p></span>" & "<br />"
.Display
End With
ExitProc:
Set Msg = Nothing
' we need to call the Quit method, to quit Outlook if we actually started it ourselves
If bWeStartedOutlook Then olApp.Quit
Set olApp = Nothing
Application.StatusBar = False
Application.ScreenUpdating = True
End Sub