|
[x]
Posted via EE Mobile
|
|
| Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
|
|
|
|
Asked by mohitgauri in Microsoft Applications, Microsoft Access Database, Visual Basic Programming
Whenever I send an email using the code below, everything works fine. My message goes into Microsoft Outlook and sends an email. The problem is that I always have to click OK in a window which pops up everytime it tries to send an email.
Error window message "The command line argument is not valid. Verify the switch you are using."
Looking forward for any help. Thanks in advance.
PS: I am using Access 97 to send email using Outlook 2003.
Mohit
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
|
Sub SendAnEmailWithOutlook()
' creates and sends a new e-mail message with 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 ' creates a new e-mail message
With olMailItem
.subject = "Subject for the new e-mail message" ' message subject
Set ToContact = .Recipients.add("myself@email.com") ' add a recipient
Set ToContact = .Recipients.add("myself@email.com") ' add a recipient
ToContact.Type = olCC ' set latest recipient as CC
Set ToContact = .Recipients.add("myself@email.com") ' add a recipient
ToContact.Type = olBCC ' set latest recipient as BCC
.Body = "This is the message text" & Chr(13)
.send ' sends the e-mail message (puts it in the Outbox)
End With
Set ToContact = Nothing
Set olMailItem = Nothing
Set OLF = Nothing
End Sub
|
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625