Results 1 to 10 of 10

Thread: Possibly Very Difficult!!

  1. #1

    Thread Starter
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425
    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

  2. #2
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341
    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).

  3. #3

    Thread Starter
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425

    Talking

    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?

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    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.

  5. #5
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341

    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.

  6. #6
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    regarding parsing and writing to INI's. You need the structure like this

    Code:
    [Header]
    [email protected]
    [email protected]
    BCC=NULL
    
    [Body]
    MESSAGE=Hi this is a test
    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]

  7. #7
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    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]

  8. #8
    Guest
    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

  9. #9
    Frenzied Member
    Join Date
    Jun 2000
    Location
    England, Buckingham
    Posts
    1,341

    Arrow

    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.

  10. #10

    Thread Starter
    Hyperactive Member CyberSurfer's Avatar
    Join Date
    Aug 2000
    Location
    Old London Town
    Posts
    425
    Thanks Guys!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width