|
-
Oct 7th, 2000, 09:06 AM
#1
Thread Starter
Hyperactive Member
I'm writing an email program which will allow you to save emails to send later. I know how to create a file association, but have an other problem.
When the file is double clicked, I want to insert the information from into the correct fields in one of the forms in my program, ie
a) Recipient
b) CC
c) BCC
d) Message Body
If anyone has any ideas on how to go about this, I would be extremely grateful.
THX
-
Oct 7th, 2000, 09:20 AM
#2
Frenzied Member
The file that stores the actual message would nned to have the structure of an ini file where by you can put all of the data into each section. So you could have.
[email protected]
CC=NULL
BCC=NULL
MESSAGE=Hi bob ive just made this app and sent you some stuff.
This is a fairly easy concept, (writing and reading from ini files).
-
Oct 7th, 2000, 09:34 AM
#3
Thread Starter
Hyperactive Member
Thanks PsyVision!
Unfortunately, I have never done anything with ini files before. Is there a turorial on VB-World? If not, could you pleeeeeease explain it to me?
-
Oct 7th, 2000, 10:08 AM
#4
Frenzied Member
Is there a tutorial on Vb-World.net?
You could do a search yourself, but because we're all nice I did it for you!
http://www.vb-world.net/cgi-bin/sear...hereto=VBWORLD
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 7th, 2000, 10:14 AM
#5
Frenzied Member
This is the simplest...
The Api Declares you need are:
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationname As String, ByVal lpKeyName As Any, ByVal lsString As Any, ByVal lplFilename As String) As Long
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationname As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Here is what is in the Ini File (Message.ini):
[Email]
[email protected]
Cc=NULL
Bcc=NULL
Message=Hello Fred Hows You Doing.
The Code for the app:
Dim To as string
Dim Cc as string
Dim Bcc As string
Dim Message as stringDim ret As Long
Dim Temp As String * 50
Dim lpAppName As String, lpKeyName As String, lpDefault As String, lpFileName As String
Private Sub Form_Load()
LoadMessage app.path & "\Message.ini"
End Sub
Public Sub LoadMessage(strFile as string)
lpAppname = "Email"
lpKeyName = "To"
lpDefault = "NULL"
lpFilename = strFile
ret = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, Temp, Len(Temp), lpFileName)
If ret = 0 then
beep
else
To = Trim(Temp)
end if
lpAppname = "Email"
lpKeyName = "Cc"
lpDefault = "NULL"
lpFilename = strFile
ret = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, Temp, Len(Temp), lpFileName)
If ret = 0 then
beep
else
Cc = Trim(Temp)
end if
lpAppname = "Email"
lpKeyName = "Bcc"
lpDefault = "NULL"
lpFilename = strFile
ret = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, Temp, Len(Temp), lpFileName)
If ret = 0 then
beep
else
Bcc = Trim(Temp)
end if
lpAppname = "Email"
lpKeyName = "Message"
lpDefault = "NULL"
lpFilename = strFile
ret = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, Temp, Len(Temp), lpFileName)
If ret = 0 then
beep
else
Message = Trim(Temp)
end if
End Sub
Give it a whiz, it should work.
-
Oct 7th, 2000, 10:19 AM
#6
Fanatic Member
regarding parsing and writing to INI's. You need the structure like this
Then you use the API functions GetPrivateProfileString and WritePrivateProfileString
See here at vbapi.com
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Oct 7th, 2000, 10:20 AM
#7
Fanatic Member
PsyVision, i was looking up the functions at vbapi.com while you posted, didn't notice until after i did.
GWDASH
[b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]
-
Oct 7th, 2000, 10:21 AM
#8
Try this easy-to-understand INI example:
Code:
Public Declare Function GetPrivateProfileString _
Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal _
lpApplicationName As String, ByVal lpKeyName As String, _
ByVal lpDefault As String, ByVal lpReturnedString As _
String, ByVal nSize As Long, ByVal lpFileName As String) As _
Long
Public Declare Function WritePrivateProfileString _
Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal _
lpApplicationName As String, ByVal lpKeyName As Any, ByVal _
lpString As Any, ByVal lpFileName As String) As Long
Public Function ReadINI(strsection As String, strkey As String, strfullpath As String) As String
Dim strbuffer As String
Let strbuffer$ = String$(750, Chr$(0&))
Let ReadINI$ = Left$(strbuffer$, GetPrivateProfileString(strsection$, ByVal LCase$(strkey$), "", strbuffer, Len(strbuffer), strfullpath$))
End Function
Public Sub WriteINI(strsection As String, strkey As String, strkeyvalue As String, strfullpath As String)
Call WritePrivateProfileString(strsection$, UCase$(strkey$), strkeyvalue$, strfullpath$)
End Sub
'Usage:
'Write
'Call WriteINI("Value.ini", "Value", "1", "C:\Value.ini")
'Read
'x = ReadINI("Value.ini", "Value", "C:\Value.ini")
'MsgBox x
-
Oct 7th, 2000, 10:23 AM
#9
Frenzied Member
Option Explicit
Dim ret As Long
Dim Temp As String * 50
Dim lpAppName As String, lpKeyName As String, lpDefault As String, lpFileName As String
Private Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationname As String, ByVal lpKeyName As Any, ByVal lsString As Any, ByVal lplFilename As String) As Long
Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationname As String, ByVal lpKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Private Sub Form_Load()
LoadMessage App.Path & "\Message.ini"
End Sub
Public Sub LoadMessage(strFile As String)
lpAppName = "Email"
lpKeyName = "To"
lpDefault = "NULL"
lpFileName = strFile
ret = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, Temp, Len(Temp), lpFileName)
If ret = 0 Then
Beep
Else
txtTo = Trim(Temp)
End If
lpAppName = "Email"
lpKeyName = "Cc"
lpDefault = "NULL"
lpFileName = strFile
ret = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, Temp, Len(Temp), lpFileName)
If ret = 0 Then
Beep
Else
txtCc = Trim(Temp)
End If
lpAppName = "Email"
lpKeyName = "Bcc"
lpDefault = "NULL"
lpFileName = strFile
ret = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, Temp, Len(Temp), lpFileName)
If ret = 0 Then
Beep
Else
txtBcc = Trim(Temp)
End If
lpAppName = "Email"
lpKeyName = "Message"
lpDefault = "NULL"
lpFileName = strFile
ret = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, Temp, Len(Temp), lpFileName)
If ret = 0 Then
Beep
Else
txtMessage = Trim(Temp)
End If
End SubYou could Have 1 single file that contains all the messages by replacing the string lpAppName with the message number, (give each mail a unique number), then you can just make it so when you click on a list of messages it sets lpAppName to the mail number and loads it.
-
Oct 7th, 2000, 10:27 AM
#10
Thread Starter
Hyperactive Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|