473,402 Members | 2,046 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,402 software developers and data experts.

Opening a Draft E-mail or an e-mail in edit mode.

I was prompted to think about this by a couple of MLH's recent posts.
Whether this is what he !!!!really!!!! wanted, I don't know.

This code is supposed to open an e-mail in edit mode, although I have
called it "draft". It's pretty simple. It just creates an .eml file, in
eml format, and then calls ShellExecute to open the file (I tried
Application.FollowHyperlink first; that works but results in two
warning messages on my machine.) Some e-mail programs when set as the
default will also make themselves the default opener of .eml files so
on my machine this opens in Thunderbird and I can edit, save as a
draft, send or delete it.

Private Declare Function ShellExecute& Lib "shell32.dll" _
Alias "ShellExecuteA" _
( _
ByVal Window&, _
ByVal Operation$, _
ByVal File$, _
ByVal Parameters$, _
ByVal Directory$, _
ByVal Show&)

Public Sub Draft( _
ByVal from$, _
ByVal recipients$, _
ByVal subject$, _
ByVal body$, _
Optional ByVal cc$, _
Optional ByVal bcc$, _
Optional ByVal priority&)

Dim buffer$
Dim filenumber%
Dim filename$
Dim path$

On Error GoTo DraftErr:

buffer = "From:" & Chr(34) & from & Chr(34)
buffer = buffer & vbNewLine & "To:" & Chr(34) & recipients & Chr(34)
If Len(cc) 0 Then _
buffer = buffer & vbNewLine & "CC:" & Chr(34) & cc & Chr(34)
If Len(bcc) 0 Then _
buffer = buffer & vbNewLine & "BCC:" & Chr(34) & bcc & Chr(34)
buffer = buffer & vbNewLine & "Subject:" & Chr(34) & subject & Chr(34)
If priority < 1 Or priority 3 Then _
priority = 3
buffer = buffer & vbNewLine & "X_priority:" & priority
buffer = buffer & vbNewLine & "X_Unsent: 1"
buffer = buffer & vbNewLine
buffer = buffer & vbNewLine & body

path = Environ("temp")
filename = path & "\temp.eml"
' I doubt this line is necessary
' in VBA but it may be
' in languages where "\"
' is a literal precursor
filename = Replace(filename, "\", "/")

On Error Resume Next
Kill filename
On Error GoTo DraftErr:

filenumber = FreeFile()
Open filename For Binary As #filenumber
Put #filenumber, , buffer
Close #filenumber

ShellExecute 0, "Open", "file://" & filename, "", "", 0

DraftExit:
Close
Exit Sub

DraftErr:
With Err
MsgBox "Error Number " & .Number & vbNewLine & .Description,
vbCritical, "Draft Creation Failed"
End With
Resume DraftExit
End Sub

Sub testDraft()
Draft "so*****@some.domain", "so*********@someother.domain",
"Draft", "This is a test."
End Sub

Oct 2 '06 #1
0 1406

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

Similar topics

8
by: Gilles T. | last post by:
How I can get element ID in the edit mode of datagrid control? If I not in the edit mode, there are no problem. <asp:TemplateColumn ItemStyle-CssClass="grid_column_width_3"...
6
by: Tamir Khason | last post by:
How to prevent the selected cell from being editable (visual) at DataGrid? Once click on cell (even readonly) there are cursor inside it and select text appears. How to prevent it Thankx
1
by: sck10 | last post by:
Hello, I am trying to change a value when a user goes into edit mode on a DetailsView control. I am trying to use the following, but can not figure out how to get to the bound field...
3
by: Woody Splawn | last post by:
We have a client server application where we would like to not show Save and Cancel buttons on a winform until the user has actually entered something into a textbox or combobox etc., and there is...
2
by: Luqman | last post by:
How can I put GridView and DetailView control to Edit Mode with one click of button ? I don't want to show built-in Edit Buttons of above controls. Best Regards, Luqman
4
by: wandii | last post by:
Hi, I have a datagrid attached to a dataset. It displays the records fine however, when I edit one of the cells it does not change the edit icon to the pencil icon on the left of the row I just...
1
by: phamer | last post by:
Hello. My switchbaord contains 2 options: add a record and edit a record. So, of course, if I click add a record, the first form opens in add mode; if I click edit, the first form opens in edit...
1
by: Mark Stafford | last post by:
I am attempting to use a DetailsView control to view some data where the fields returned by the database are determined at runtime. I create the TemplateFields on the fly using a class that...
4
by: khalid sohail | last post by:
hi i wnat to open the datagrid in edit mode when the page load....any help will be aperiecated greatly...........tell me the code how to do that... thenx in advance
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.