- '------------------------------------------------- -----
- 'Object untuk membuat Project ini:
- 'TextBox bernama txtWeb dengan teks diatur ke http://www.
- 'tombol bernama cmdWeb
- ' Listing module
- Dim success As Integer
- Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
- (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
- ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
- '------------------------------------------------------------------
- 'Listing Tombol
- Private Sub cmdWeb_Click()
- Dim success As Integer
- If Trim(txtWeb.Text) = "http://www." Or Trim(txtWeb.Text) = "" Then ' I have the txtWeb.text set to http://www.
- MsgBox "You don't have a web address entered for this entry", vbCritical, "Missing Data"
- ElseIf Left(Trim(txtWeb.Text), 11) = "http://www." Then
- Site = Trim(txtWeb.Text)
- ElseIf Left(Trim(txtWeb.Text), 4) = "www." Then
- Site = "http://" & Trim(txtWeb.Text)
- Else
- Site = "http://www." & Trim(txtWeb.Text)
- End If
- success% = ShellToBrowser(Me, Site, 0)
- End Sub
- '------------------------------------------------------------------
- ' Here's the function code
- Function ShellToBrowser%(Frm As Form, ByVal URL$, ByVal WindowStyle%)
- Dim api%
- api% = ShellExecute(Frm.hwnd, "open", URL$, "", App.Path, WindowStyle%)
- 'Check return value
- If api% <31 Then
- 'error code - see api help for more info
- MsgBox App.Title & " had a problem running your web browser. & _
- "You should check that your browser is correctly installed." & _
- (Error" & Format$(api%) & ")", 48, "Browser Unavailable"
- ShellToBrowser% = False
- ElseIf api% = 32 Then
- 'no file association
- MsgBox App.Title & " could not find a file association for " & _
- URL$ & " on your system. You should check that your browser" & _
- "is correctly installed and associated with this type of file.", 48, "Browser Unavailable"
- ShellToBrowser% = False
- Else
- 'It worked!
- ShellToBrowser% = True
- End If
- End Function
- Private Sub cmdEmail_Click()
- Dim success As Integer
- If Trim(txtEmail.Text) = "" Then ' Give an error if nothing is in the text box
- MsgBox "You don't have an email address entered for this entry", vbCritical, "Missing Data"
- Else
- Site = "mailto:" & Trim(txtEmail.Text)
- success% = ShellToBrowser(Me, Site, 0)
- End If
- End Sub
- Dim oApp As Outlook.Application
- Dim oNameSpace As NameSpace
- Dim oFolder As MAPIFolder
- Dim oMailItem As Object
- Dim sMessage As String
- Set oApp = New Outlook.Application
- Set oNameSpace = oApp.GetNamespace("MAPI")
- Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
- For Each oMailItem In oFolder.Items
- With oMailItem
- If oMailItem.Attachments.Count > 0 Then '?
- oMailItem.Attachments.Item(1).SaveAsFile "C:\Temp\Outlook
- Attachments\" & oMailItem.Attachments.Item(1).filename
- MsgBox oMailItem.Attachments.Item(1).DisplayName & " was
- saved as " & oMailItem.Attachments.Item(1).filename
- End If
- End With
- Next oMailItem
- Set oMailItem = Nothing
- Set oFolder = Nothing
- Set oNameSpace = Nothing
- Set oApp = Nothing
Klik Like/share jika anda menyukai tulisan
0 Reply :
Posting Komentar
Jika ada pertanyaan atau request,Komentar pada tab blogger akan lebih memudahkan saya untuk membalasnya karena lebih mudah melakukan pengecekan komentar.