|
| email Fra : Ditte og Anders Zusc~ |
Dato : 14-09-01 16:52 |
|
Hej
Tidligere har der været en tråd mht at maile via vb5.
Følgende virker fint:
Public 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
public const email = "en eller anden emailadresse"
Public Sub sendemail()
Dim Success As Long
Success = ShellExecute(0&, vbNullString, "mailto:" & email, vbNullString,
"C:\", SW_SHOWNORMAL)
End Sub
Men--- hvad nu hvis man også har en streng bestående af flere navne adskilt
af semikolon, som man gerne vil have i Cc-feltet? Kan det lade sig gi' sig
monstro? Og hvad med emnet? Kan det også angives via koden?
VH AZ
| |
Jan Damkjær Dahl (14-09-2001)
| Kommentar Fra : Jan Damkjær Dahl |
Dato : 14-09-01 17:52 |
|
Følgende funktion kan gøre det, eller i hvertfald noget af det.
SendMail Mail, Emne, Besked
Public Function SendMail(sEmailRecipient As String, sEmailSubject As String,
sEmailBody As String)
'-----Send an Email Message using Outlook -----
'Developers Note: In References, the Microsoft Outlook Object Model must be
selected for this to work
Dim emailOutlookApp As Outlook.Application
Dim emailNameSpace As Outlook.NameSpace
Dim emailFolder As Outlook.MAPIFolder
Dim emailItem As Outlook.MailItem
Dim EmailRecipient As Recipient
'-----Open Outlook in a background process and the Inbox Folder-----
Set emailOutlookApp = CreateObject("Outlook.Application")
Set emailNameSpace = emailOutlookApp.GetNamespace("MAPI")
Set emailFolder = emailNameSpace.GetDefaultFolder(olFolderInbox)
'Enable the next line to actually see Outlook Open
'emailFolder.Display
'-----Create a new mail message, set the recipient, subject, and body-----
Set emailItem = emailOutlookApp.CreateItem(olMailItem)
Set EmailRecipient = emailItem.Recipients.Add(sEmailRecipient)
emailItem.Subject = sEmailSubject
emailItem.Body = sEmailBody
'emailItem.Display 1
'MsgBox "Hallo"
'-----Send the Email-----
emailItem.Save
emailItem.Send
'-----Close the Outlook Application------
'emailOutlookApp.Quit
'----Inform User of Success-----
'MsgBox "Email was sent.", vbInformation
'-----Clear out the memory space held by variables-----
'Usually unnecessary but a good practice
Set emailNameSpace = Nothing
Set emailFolder = Nothing
Set emailItem = Nothing
Set emailOutlookApp = Nothing
End Function
"Ditte og Anders Zuschlag" <zuschlag@mail.tele.dk> skrev i en meddelelse
news:3ba22847$0$82130$edfadb0f@dspool01.news.tele.dk...
> Hej
> Tidligere har der været en tråd mht at maile via vb5.
> Følgende virker fint:
>
> Public 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
> public const email = "en eller anden emailadresse"
>
> Public Sub sendemail()
> Dim Success As Long
>
> Success = ShellExecute(0&, vbNullString, "mailto:" & email, vbNullString,
> "C:\", SW_SHOWNORMAL)
>
> End Sub
>
>
> Men--- hvad nu hvis man også har en streng bestående af flere navne
adskilt
> af semikolon, som man gerne vil have i Cc-feltet? Kan det lade sig gi' sig
> monstro? Og hvad med emnet? Kan det også angives via koden?
> VH AZ
>
>
>
>
>
>
| |
|
|