|
||||
Disse websidene oppdateres ikke lengre og er kun tilgjengelig for historikken sin skyld.Klikk her for å gå til den oppdaterte informasjonen. Kontrollere Outlook fra ExcelDe to eksempelmakroene nedenfor viser hvordan man kan sende informasjon til
Outlook (f.eks. sende en e-postmelding) og hvordan man kan hente informasjon fra
Outlook (f.eks. returnere en liste over alle meldingene i Innboksen). ' krever referanse til Microsoft Outlook 8.0 Object Library
Sub SendEnEpostMedOutlook()
' oppretter og sender en e-postmelding med Outlook
Dim OLF As Outlook.MAPIFolder, olMailItem As Outlook.MailItem
Dim ToContact As Outlook.Recipient
Set OLF = GetObject("", _
"Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
Set olMailItem = OLF.Items.Add ' oppretter e-postmeldingen
With olMailItem
.Subject = "Meldingstittel" ' meldingens tittel
Set ToContact = .Recipients.Add("name@domain.com")
' legger til en mottaker
Set ToContact = .Recipients.Add("name@company.com")
' legger til en mottaker
ToContact.Type = olCC ' angi at siste mottaker skal ha en kopi
Set ToContact = .Recipients.Add("name@org.net")
' legger til en mottaker
ToContact.Type = olBCC ' angi at siste mottaker skal ha en blindkopi
.Body = "This is the message text" & Chr(13)
' meldingsteksten med et linjeskift
.Attachments.Add "C:\FolderName\Filename.txt", olByValue, , _
"Attachment" ' setter inn et vedlegg
' .Attachments.Add "C:\FolderName\Filename.txt", olByReference, , _
"Shortcut to Attachment" ' setter inn en snarvei
' .Attachments.Add "C:\FolderName\Filename.txt", olEmbeddedItem, , _
"Embedded Attachment" ' setter inn et innebygget vedlegg
' .Attachments.Add "C:\FolderName\Filename.txt", olOLE, , _
"OLE Attachment" ' setter inn et OLE vedlegg
.OriginatorDeliveryReportRequested = True ' angir leveringsbekreftelse
.ReadReceiptRequested = True ' angir lesebekreftelse
'.Save ' lagrer meldingen for senere redigering
.Send ' sender meldingen (legger den i Utboksen)
End With
Set ToContact = Nothing
Set olMailItem = Nothing
Set OLF = Nothing
End Sub
Sub ListInnboksInnhold()
Dim OLF As Outlook.MAPIFolder, CurrUser As String
Dim EmailItemCount As Integer, i As Integer, EmailCount As Integer
Application.ScreenUpdating = False
Workbooks.Add ' lager en ny arbeidsbok
' add headings
Cells(1, 1).Formula = "Tittel"
Cells(1, 2).Formula = "Mottatt"
Cells(1, 3).Formula = "Vedlegg"
Cells(1, 4).Formula = "Lest"
With Range("A1:D1").Font
.Bold = True
.Size = 14
End With
Application.Calculation = xlCalculationManual
Set OLF = GetObject("", _
"Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(olFolderInbox) ' innboksen
EmailItemCount = OLF.Items.Count
i = 0: EmailCount = 0
' leser e-post informasjon
While i < EmailItemCount
i = i + 1
If i Mod 50 = 0 Then Application.StatusBar = _
"Leser e-postmeldinger " & _
Format(i / EmailItemCount, "0%") & "..."
With OLF.Items(i)
EmailCount = EmailCount + 1
Cells(EmailCount + 1, 1).Formula = .Subject
Cells(EmailCount + 1, 2).Formula = _
Format(.ReceivedTime, "dd.mm.yyyy hh:mm")
Cells(EmailCount + 1, 3).Formula = .Attachments.Count
Cells(EmailCount + 1, 4).Formula = Not .UnRead
End With
Wend
Application.Calculation = xlCalculationAutomatic
Set OLF = Nothing
Columns("A:D").AutoFit
Range("A2").Select
ActiveWindow.FreezePanes = True
ActiveWorkbook.Saved = True
Application.StatusBar = False
End Sub
Dokumentet er sist oppdatert 2000-04-12 12:35:01
|
||||
| ||||