473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Creating EMAIL from VBA (behind a form)

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 ***
Nov 13 '05 #1
2 7603
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:
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 ***


Nov 13 '05 #2
On Tue, 25 Oct 2005 09:57:07 GMT, Susan Bricker <sl*****@verizon.net>
wrote:
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?


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

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Iain Miller | last post by:
Now this shouldn't be hard but I've been struggling on the best way as to how to do this one for a day or 3 so I thought I'd ask the assembled company..... I'm writing an application that tracks...
0
by: James Fortune | last post by:
Here is an example of Access creating a single page PDF file. The text in the textbox is scaled to fit horizontally into a grey box 100 pixels wide that is fontsize pixels high. Clicking the...
3
by: Matt Smolic | last post by:
Does anyone know where I can get some info on creating customer account numbers, part numbers and such. In other words what the logic is behind their creation. I am not looking for code, just how...
12
by: enak | last post by:
I have found some code that shows how to convert an html form to Word. The message said to simply put the following in the Page_load: Response.ContentType = "application/ms-word"...
1
by: Niks | last post by:
Hi, I am new to ASP.NET. I have to develop a SIMPLE web based project in ASP.NET. I have a few questions reagarding that - 1) Do we need to create a new project by selecting ASP.NET web...
0
by: Ing. Rajesh Kumar | last post by:
Hi everybody When creating a web project using VS.NET and then publishing using the "copy only files needed to run this project", there is only one DLL and HTML (aspx) pages in the destination...
5
by: | last post by:
Trying to learn about manipulating collections of objects, and populating these objects dynamically from datasources. Could someone post a code sample that shows the following: Instantiating a...
3
by: =?Utf-8?B?RGF2ZQ==?= | last post by:
I design all of my pages in expression web. I then want to create a code behind file for the aspx page created by EW in VS 2005. How could I do this easily?
4
by: zufie | last post by:
I have a main form containing a command SEND button that prompts an email form to pop up. The email address(es) that are supposed to appear on the email form are those corresponding to the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.