Connecting Tech Pros Worldwide Help | Site Map

Creating EMAIL from VBA (behind a form)

Susan Bricker
Guest
 
Posts: n/a
#1: Nov 13 '05
I know that it is possible to generate an email letter and send it from
VBA behind a form. I've done that. However, is it possible to create a
DRAFT email letter and leave it in the Drafts folder (in Microsoft
Outlook)? If it is possible, would you share the source code with me?

Thanks.

Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***
telepro
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Creating EMAIL from VBA (behind a form)


hello sueB,

i have an access application that reads outlook draft folder contents
and list it in a listbox-control to expose it to the users, then they
can doble-click one item and edit it that way.

well i think that what you have to do is to set an instance of a new
mail-item and instead of send it just save it to the draft folder.

does it help??.

+regards,

Susan Bricker wrote:[color=blue]
> I know that it is possible to generate an email letter and send it from
> VBA behind a form. I've done that. However, is it possible to create a
> DRAFT email letter and leave it in the Drafts folder (in Microsoft
> Outlook)? If it is possible, would you share the source code with me?
>
> Thanks.
>
> Regards,
> SueB
>
> *** Sent via Developersdex http://www.developersdex.com ***[/color]

Chuck Grimsby
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Creating EMAIL from VBA (behind a form)


On Tue, 25 Oct 2005 09:57:07 GMT, Susan Bricker <slbrick@verizon.net>
wrote:[color=blue]
>I know that it is possible to generate an email letter and send it from
>VBA behind a form. I've done that. However, is it possible to create a
>DRAFT email letter and leave it in the Drafts folder (in Microsoft
>Outlook)? If it is possible, would you share the source code with me?[/color]

Public Sub SendMailWithAttachment( _
strTo As String, _
strAttachmentFiles As String, _
Optional strSubject As String = "", _
Optional strBodyText As String = "", _
Optional bolQuitOutlook As Boolean = False, _
Optional bolSendAsDraft As Boolean = True)

Dim OL As Object
Dim OLNS As Object 'Outlook.NameSpace
Dim MailFolder As Object 'Outlook.MAPIFolder
Dim MyMail As Object 'Outlook.MailItem
Dim varAttachments As Variant
Dim I As Integer

varAttachments = Split(strAttachmentFiles, Chr$(0))
Set OL = CreateObject("Outlook.Application")
Set OLNS = OL.GetNamespace("MAPI")
If bolSendAsDraft = True Then
Set MailFolder = OLNS.GetDefaultFolder(16)
Else
Set MailFolder = OLNS.GetDefaultFolder("Inbox")
End If
Set MyMail = MailFolder.Items.Add

With MyMail
.To = strTo
.Subject = strSubject
.Body = strBodyText
For I = 0 To UBound(varAttachments)
If CStr(varAttachments(I)) <> "" Then _
.Attachments.Add CStr(varAttachments(I)), _
1, _
I + 1
Next
.Recipients.ResolveAll
.Save
If bolSendAsDraft = False Then
.Send
End If
End With
If bolQuitOutlook = True Then OL.Quit
Set MyMail = Nothing
Set MailFolder = Nothing
Set OLNS = Nothing
Set OL = Nothing
End Sub


--
Drive C: Error. (A)bort (R)etry (S)mack The Darned Thing

Closed Thread