Creating EMAIL from VBA (behind a form)

  • Permalink
  • submit to reddit
  • Email
  • Follow


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 ***
0
Reply slbrick (181) 10/25/2005 9:57:07 AM

See related articles to this posting

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 ***

0
Reply teleprogramador (1) 10/25/2005 7:07:57 PM

On Tue, 25 Oct 2005 09:57:07 GMT, Susan Bricker <slbrick@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

0
Reply c.grimsby (825) 10/25/2005 10:26:24 PM
comp.databases.ms-access 42170 articles. 10 followers. Post

2 Replies
171 Views

Similar Articles

[PageSpeed] 0

  • Permalink
  • submit to reddit
  • Email
  • Follow


Reply:

Similar Artilces:

creating an email in digest form
How can I take a folder created with sendmail/procmail and forward the whole file so that it appears in digest form to the receipient? I tried to make sense of `forw` but failed :( On 1 Jul 2004 10:01:05 -0700, Your name <catcher39@www.com> wrote: > > > How can I take a folder created with sendmail/procmail and forward the > whole file so that it appears in digest form to the receipient? > I tried to make sense of `forw` but failed :( Take a look at this: http://www.faqs.org/rfcs/rfc1153.html If you need help writing a script to create digests from your mailboxes, ge...

Create an HTML email with forms...
Hi all, I'm trying to understand how can I send an email and format the body as an html page.. here the code: <?php $student_ID = $_REQUEST['studentID']; // sending email $emailsubject = "Web Enquiry from " . $student_ID; $headers = "From: webform@test.com.au\r\n"; $headers .= "Content-type: text/html\r\n"; $toEmail = "test@test.com.au"; $body= "</html>"; $body.= "<h1>Make an Enquiry:</h1>"; $body.= "<form action=\"\" method=\"post\">"; $body.= &...

Trying to create an email with form data.
Hi I'm having trouble writing to an excel spreadsheet. I have the following code Dim strList As String With Me.trainingplan.Form.RecordsetClone .MoveFirst While Not .EOF strList = strList & vbCrLf & Nz(.Fields("Course")) .MoveNext Wend End With This loops to store all the values in Course on a Continuous Form. i Now want to email this data. I tried to put this into an email as text but it didnt take the vbCrLf and ended up as one big long line of text. I tried an email as html as well using <BR>/ But tha...

How to define an Array in VBA behind the Access Forms
Hi. I would like to create an array and use the data to populate some new records when the user clicks on a button (that's the short description). If I were to code the array in C (I know ... not this forum, but it's what I know) I would do it like this ... /* Declare the structure template */ struct recdata { long classID; char lvl; }; I would then define the array of structs as follows: struct recdata classinfo[8] = {{ 0x01, "A" }, { 0x01, "B" }, { 0x01, "C" }, { 0x02, "A" }, { 0x02, "B" }, { 0x02, "C...

Creating a Lotus Notes Email in MS Access and VBA
This may seem like an MS access question, but it is really a Lotus Notes email question. I have an Access database that checks records and creates a Lotus Notes email based on what it finds in the records. It works great. Except that sometimes the email I create has too many characters for Lotus Notes variables. In other words, I create a variable in my Access routine that holds the "message". But I can not seem to string two variable together. For example, if I want to write in my email: ----- Dear store manager: The following items are out of stock in your s...

Creating an email with attachments from an Access Form using VB
If someone could help me, I need to be able to send attachments from my access database that I have created. This database runs queries then generates a report off the queries from underlying tables and emails the reports as HTML format in the body, I then need to have this same process go out to my C:\ drive and pick up a couple files and add it to the same email as attachments. If someone could please give me a sample code that would work, please as simple as it could be would be best because I know very little with VB. Thanks I have been using the following function. I hope it helps &...

Creating a Lotus Notes Email in MS Access and VBA
This may seem like an MS access question, but it is really a Lotus Notes email question. I have an Access database that checks records and creates a Lotus Notes email based on what it finds in the records. It works great. Except that sometimes the email I create has too many characters for Lotus Notes variables. In other words, I create a variable in my Access routine that holds the "message". But I can not seem to string two variable together. For example, if I want to write in my email: ----- Dear store manager: The following items are out of stock in your s...

Creating a distribution list form thousands of email using an agent
I'm soemewhat new to Lotus so any help is greatly appreciated. We are using Notes 6.02CF. We have thousands of emails that I would like to automatically create a distribution list using an agent. I've tried writting one using one but doesn't work too well. Please let me know the best approach to this and any coding examples. Thank you so mcuh in advance! dgreen@fs.fed.us wrote: > I'm soemewhat new to Lotus so any help is greatly appreciated. We are > using Notes 6.02CF. We have thousands of emails that I would like to > automatically create a distribu...

Creating a distribution list form thousands of email using an agent or other
I'm soemewhat new to Lotus so any help is greatly appreciated. We are using Notes 6.02CF. We have thousands of emails that I would like to automatically put in a distribution list using an agent or other. The idea is to select all the email, invoke the agent or other and have all the senders emails placed in a distribution list. I've tried writting one but doesn't work too well. Please let me know the best approach to this and any coding examples. Thank you so much in advance! dgreen@fs.fed.us wrote: > I'm soemewhat new to Lotus so any help is greatly appreciat...

Creating custom forms with a form...
This is more of a structural question (me: newbie) as opposed to specific coding. Please be patient... I'm making a database for the small company I work for. It will be to add and edit products listed on our e-commerce site. I would like to have a customized form for each group of similar products ("drills, for instance, would be a similar group of products - although there are further groups within the group of "drills"...). Every product will share standard fields like "product number" and "price" but there are many product specifications that are sp...

forms/email/capturing info from a form?
Hi all! OK I admit it I'm new at java & java scripts. I have been asked to create a registration form for a club page on the web. I have been able to create my input boxes and am now trying to find a way to get the material entered in the boxes to populate an email to myself. Ideally, I want this to be done without the registrant having to see it. Can anyone help me out here? Drew Kellas wrote: > OK I admit it I'm new at java & java scripts. I have been asked to > create a registration form for a club page on the web. I have been > able to create my input boxes an...

Creating a form that creates a unique query
For a project I have been asked to create a database system for use in an Estate Agents. Obviously the main function of such a system would be the need for a user to seach through the database for properties that match a certain set of criteria. The problem is this: I need to create a form that allows a user to select for each field of data held about the property a value. For instance someone wants to seach for A house with 2+ Bedrooms, that costs below =A3150,000. The number of criteria could be less or more, however I need to be able select as few or as many critera on one form (obviously ...

forms/email/capturing info from a form?
Hi all! OK I admit it I'm new at java & java scripts. I have been asked to create a registration form for a club page on the web. I have been able to create my input boxes and am now trying to find a way to get the material entered in the boxes to populate an email to myself. Ideally, I want this to be done without the registrant having to see it. Can anyone help me out here? Drew Kellas wrote: > OK I admit it I'm new at java & java scripts. Okay. You should start by realizing that there are two completely different languages: one called Java and one called JavaScript...

Form created as datasheet; displays as single form
Re: Access 2000 I have a form (Form1) where the default view in the properties is set to "Datasheet". When I click on the Form1 object from the container to display it, it displays fine in datasheet mode. However, when I click a button on another form to display Form1, Form 1 is displayed as single form. I need it to display Form1 in datasheet mode. Here is my code in the click event that opens the form: <begin code> Private Sub cmdDivCodes2_Click() On Error GoTo Err_cmdDivCodes2_Click Dim stDocName As String Dim stLinkCriteria As String stDocName = "frmD...

Creating an editable PDF Form From a Paper Form
I have a business that requires me to regularly file permit applications. I would like to convert this paper form to a pdf form that will allow me to type the information into the pertinent fields and print it out for faxing or mailing. My pdf software is Foxit Pro (which allows me to type info in the proper fields in existing PDF forms). I'm not quite sure of the simplest way to accomplish this: 1) I suppose I could just reproduce the form in Word and convert it to pdf. Of course, this would be time intensive (and would it allow me to enter type in the proper places?). 2) Perhaps...

create a form with Skill that create a file from library manager
I am developping a tool with skill language that generate automaticaly a testchip from a file that describe tle list of cells of the testchip. I want to create from an interface this file that contains in each line : "name of a library" "name of the cell" "the view of the cell" "the position of the cell in the testchip" the interface will contain a button called "BROWSE" when we click on the button the library manager appears and we choose the library, the cell name and the cell view , in this moment a file should be created containing all ...

How to have email form send email and start file download
Last week after much searching, I found the answer to my problem in this newsgroup. I can't find the thread from which I got my solution, but I wanted to report back what worked. When the site visitor fills out the form and submits it, this calls a rather ordinary asp script like formmail.asp that sends the emails and displays a "thank you" web page. At the very end of my "thank you" web page I placed the following: <script type="text/javascript"> location.href="FileToDownload.exe" </script> This causes the file download to get trig...

create a form with checkbox by acquiring the form questions from excel
I&nbsp;am very confused to how to do this in labview 8 I&nbsp;have a "questionaire" in MS Excel with&nbsp;"ok" or "not ok"&nbsp;questions and a "remarks" column if "not ok" is selected. i want to transfer this questionaire to labview by a program and answer the questions in labview&nbsp;by selecting the checkboxes for "ok" and "not ok" questions and write in "remarks" column. After that i want to have the answers of checked boxes in the MS Excel spread sheet in a column or row. Can anyone help m...

Programically Create Sub-Form
Hope someone can help. I have a saved parent form containing an unbound sub-form. I set the SourceObject (form) after the Parent Form opens/loads. The sub-form (datasheet view) basically displays the results of a cross-tab query The cross-tab query is created dynamically (in code) as the column headings are subject to change. I therefore have to create a new form (in code) and add the necessary controls (fields) as per the fields in the cross-tab query. The reason why I want a form as the SourceObject of the sub-form is that it allows Event Procedures to be activated. Using a straigh...

Parameters from one form to VBA Script to another form
Hello, I have two forms - one to accept a user Id and password and the second to display a menu based on the User id and password that is entered. I am able to accept the user id and password successfully and use it in a VBA script which reads my application's internal User Table, validates the user and gets additional information from the User table such as Security Clearance, full name of the validated user. I have loaded these data values into what I presume are Global Variables. My main form is named as Main_Switchboard and its associated VBA Module has the following in the "G...

Creating Form
I need help!! I am creating a form. I want to add a value from my table. The table name is COLDST. The fields I am working with are in this same table. I want to enter Product ID and have it populate the Description and Case Pack fields. I have tried to do it with a combo box on my form and can't get it to work. <sheri@mbproducts.com> wrote > I need help!! I am creating a form. . . . > I have tried to do it with a combo > box on my form and can't get it to > work. The Combo Box wizard is very good at generating a Combo Box that selects the Record to be ...

emailing from a form
I have a table called Contact_Info. I have a form that allows me to show all the contacts from a specified city and sector. Once these contacts appear on my new form I would like to be able to press a button and it would take their email addresses, from the 'email' field, and enter them into Outlook in the "TO:" box so that they can all be emailed the same document. Any help would be much appreciated, thank you, Brendan -- Disclaimer: Any comments made are personal and do not reflect the thoughts or policies of this company. First you will need to add a reference to M...

email forms
Given how often you think this is done, is it not amazing there is on easy way to do an email form: In other words, a user clicks email on a website, and gets taken to his email program where there is a form to fill out and mail. Instead it is all handed by custom dialogs and custom servlet code. It should be possible to do it without any server side code at all. -- Canadian Mind Products, Roedy Green. Coaching, problem solving, economical contract programming. See http://mindprod.com/jgloss/jgloss.html for The Java Glossary. I don't know if I completely agree with that, if I underst...

Creating Forms
Hello All. Please pardon the question if it is not in the appropriate group. I have been asked to find out how to create forms in photoshop OR allow the code to be put in a slice in photoshop from another program. Here is what he would like to do. In PS, my boss creates a slice where the form will go. He creates the form in CuteSite Builder 4.0 and cuts the html code out. He (theoretically) pastes the code into PS/IR and VIOLA. I know nothing about this stuff, can someone please help educate through a link or first hand knowledge? I have searched the google groups and couldn't find anyt...