Microsoft Office Tutorials and References
In Depth Information
Sending a Web Page as the Body of an E-mail Message
Private Declare Function InternetCloseHandle _¶
Lib "wininet" (ByVal hInet As Long) As Integer¶
' * * * * *¶
Sub SendWebPage()¶
'Outlook Mail Item Object declaration¶
Dim objMail As MailItem¶
'String variable declaration¶
Dim strHTML As String 'HTML code variable¶
Dim URL As String 'URL address varialbe¶
'Request web page address¶
URL = InputBox("Please enter URL address. " & _¶
"(sample: www.mrexcel.com)", "Enter URL")¶
'Exit if URL is null string¶
If Trim(URL) = "" Then Exit Sub¶
'Cannot send ftp address¶
'Verify if given address is not an ftp one¶
If InStr(LCase(URL), "ftp.") = 1 Or _¶
InStr(LCase(URL), "ftp:") = 1 Then¶
MsgBox "You cannot send ftp type url. Please verify " _¶
& "the URL you entered.", _¶
vbOKOnly + vbExclamation, _¶
"The page cannot be displayed"¶
Exit Sub¶
End If¶
'Modify given URL if "http://" prefix has not been given¶
If Not LCase(Left(LCase(URL), 7)) = "http://" Then¶
URL = "http://" & URL¶
End If¶
'Retrieve HTML code of given web page¶
strHTML = GetHTMLCode(URL)¶
'If returned HTML code is empty then exit application¶
If Trim(strHTML) = "" Then¶
MsgBox "The page cannot be displayed. Please check " & _¶
"the URL you entered.", _¶
vbOKOnly + vbExclamation, _¶
"The page cannot be displayed"¶
Exit Sub¶
End If¶
'Create mail item in Outlook application¶
Set objMail = ThisOutlookSession.CreateItem(olMailItem)¶
'Insert "<BASE>" tag to refer internal items in given¶
'web page¶
'Basically telling HTML code to refer to the real¶
'web server for the objects and style sheets in web page¶
If Not InStr(1, UCase(strHTML), "<HEAD>") = 0 Then¶
strHTML = Left(strHTML, InStr(1, UCase(strHTML), _¶
"</HEAD>") - 1) & "<BASE HREF = " & _¶
URL & " TARGET=_self>" & _¶
Right(strHTML, Len(strHTML) - _¶
InStr(1, UCase(strHTML), "</HEAD>") + 1)¶
End If¶
Out
Search JabSto ::




Custom Search