Results 1 to 13 of 13

Thread: how i send Email

  1. #1

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    mail

    Hello Anavim

    This example I found on the web. its written by Jim Griffith
    Send Mail From VB5
    If Microsoft Outlook is installed, you have an easy way to
    send e-mail from VB5. To use this technique with VB3,
    remove the With construct and fully qualify each object
    property reference:
    Code:
    	Dim olapp As Object
    	Dim oitem As Object
    
    	Set olapp = CreateObject("Outlook.Application")
    	Set oitem = olapp.CreateItem(0)
    	With oitem
    		.Subject = "VBPJ RULES"
    		.To = "MONTEZUMA;other Names;"
    		.Body = "This message was sent from VB5"
    		.Send
    	End With
    And here is another example

    Send E-mail with attachment
    using MAPI.

    Use the 2 mapi objs - mpmMessage & mpsSession

    Here is the code:
    Code:
    mpsSession.SignOn
    mpmMessage.SessionID = mpsSession.SessionID
    mpmMessage.Compose
    mpmMessage.RecipAddress = "[email protected]"  'or txtAddress.text
    mpmMessage.MsgSubject = "xxxxxx"         'txtMessage.text
    mpmMessage.MsgNoteText = "Thank you"
    mpmMessage.AttachmentPathName = App.Path & "\xxx.txt"
    mpmMessage.Send False
    This code I have tried, and it works for me.

    I hope this is what you were asking for
    Onerrorgoto

    Dont be to optimistic, the light at the end of the tunnel might be a train

  2. #2
    Guest
    Or just load Outlook Express ;].

    Code:
    Shell ("start mailto:[email protected],[email protected][email protected]&subject=whatever&body=your text"), vbhide

  3. #3
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Taipei
    Posts
    318
    onerrorgoto,

    can it work in sending a bitmap attachment file?

  4. #4
    Frenzied Member Buzby's Avatar
    Join Date
    Jan 1999
    Location
    UK
    Posts
    1,670
    You could always go to http://www.PlanetSourceCode.com, search for BuzMail and download my e-mail 'object' that allows you to send e-mail using any MAPI compliant system (eg Outlook, Exchange etc) - including attachments etc.

    'Buzby'
    Visual Basic Developer
    "I'm moving to Theory. Everything works there."

  5. #5

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Exclamation I cannot se why not

    Originally posted by kmchong
    onerrorgoto,

    can it work in sending a bitmap attachment file?
    I don't think that would be any problem.
    Just state the path to the bitmap-file.
    Onerrorgoto

    Dont be to optimistic, the light at the end of the tunnel might be a train

  6. #6
    Addicted Member
    Join Date
    Apr 2000
    Location
    Sheffield, England.
    Posts
    136
    I just tried onerrorgoto's code and it didn't work.

    the mpmMessage.send causes runtime error '32002'.

    Dunno why...
    Visual Basic 6 Enterprise Edition + SP4

  7. #7
    Addicted Member
    Join Date
    Apr 2000
    Location
    Sheffield, England.
    Posts
    136
    Uh... never mind. I found the problem

    mpsSession.SignOn
    mpmMessage.SessionID = mpsSession.SessionID
    mpmMessage.Compose
    mpmMessage.RecipAddress = "[email protected]" 'or txtAddress.text
    mpmMessage.ResolveName
    mpmMessage.MsgSubject = "xxxxxx" 'txtMessage.text
    mpmMessage.MsgNoteText = "Thank you"
    mpmMessage.AttachmentPathName = App.Path & "\xxx.txt"
    mpmMessage.Send False
    Visual Basic 6 Enterprise Edition + SP4

  8. #8
    Addicted Member
    Join Date
    May 2000
    Location
    Wellington NZ
    Posts
    153

    Talking How do you get that to work

    Hi there guys, just reading your topic and was wondering how that code worked

    mpsSession.SignOn
    mpmMessage.SessionID = mpsSession.SessionID
    mpmMessage.Compose
    mpmMessage.RecipAddress = "[email protected]" 'or txtAddress.text
    mpmMessage.ResolveName
    mpmMessage.MsgSubject = "xxxxxx" 'txtMessage.text
    mpmMessage.MsgNoteText = "Thank you"
    mpmMessage.AttachmentPathName = App.Path & "\xxx.txt"
    mpmMessage.Send False

    is mpsSession an object?

    what is it? whats the full code

    Rohan

  9. #9
    Addicted Member
    Join Date
    Apr 2000
    Location
    Sheffield, England.
    Posts
    136
    You need to add the two controls found in Microsoft MAPI controls.

    MAPISession
    MAPIMessages

    You just use the properties and methods in each to send e-mail. Most of it is self explanatory.

    What I don't understand, is the MAPIMessages.ResolveName method. I only found it by trial and error.

    I also don't understand the 'False' bit after mpmMessage.Send
    Visual Basic 6 Enterprise Edition + SP4

  10. #10
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Taipei
    Posts
    318
    onerrorgoto,

    I tried your code, it works both for text and bitmaps attachments. THANKS A LOT. I have looked for this for over 2 months.

    Besides, after the .Send, it will sit in the Outlook send tray and wait for a certain period of time. Is there any way to force it to send out immediately?


  11. #11

    Thread Starter
    Hyperactive Member onerrorgoto's Avatar
    Join Date
    Aug 1999
    Location
    Sweden
    Posts
    330

    Post Maybe

    GFK:
    Resolves the name of the currently indexed recipient.

    object.ResolveName

    The object placeholder represents an object expression that evaluates to an object in the Applies To list.

    This method searches the address book for a match on the currently indexed recipient name. If no match is found, an error is returned. It does not provide additional resolution of the message originator's name or address.

    The AddressResolveUI property determines whether to display a dialog box to resolve ambiguous names.

    This method may cause the RecipType property to change.

    AddressResolveUI Property
    Specifies whether a dialog box is displayed for recipient name resolution during addressing when the ResolveName method is specified.

    object.AddressResolveUI [ = True/False]

    Setting Description
    True A dialog box is displayed with names that closely match the intended recipient's name.
    False (Default) No dialog box is displayed for ambiguous names. An error occurs if no potential matches are found (no matches is not an ambiguous situation).


    Sending the Message
    To send the message, use the Send Method. The Send method allows you to send a message with or without user interaction. Setting the value to True will display the compose message dialog box of the underlying e-mail system (Microsoft Exchange, for example). Setting it to False will send the message without displaying the compose message dialog. The following example sends the message without prompting for user interaction:

    'Send the message
    mpmMessage.Send False

    This is what MSDN say, I don't know why it doesn't send it right away. I will look some more and hopefully get an answer for you.


    [Edited by onerrorgoto on 06-29-2000 at 07:45 AM]
    Onerrorgoto

    Dont be to optimistic, the light at the end of the tunnel might be a train

  12. #12
    Guest
    I found a better way to launch default email program.
    ShellExecute is better to be used for this event instead of plain Shell.

    Code:
    Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    Private Const SW_SHOW = 5
    
    ShellExecute hwnd, "open", "mailto:[email protected],[email protected][email protected]&subject=whatever&body=your text", vbNullString, vbNullString, SW_SHOW

  13. #13
    New Member
    Join Date
    Jul 2000
    Location
    farnborough, hants
    Posts
    1

    Arrow Multiple attachments

    Hello there, Andy here, brand new member

    I see how to attach a single file to the email. But it's doesn't seem as easy to attach multiple files.
    What I need to do is attach a file for each record in the database. The paths are stored as a field so it just means looping for each record. I can see that I could create a new message for each record but ideally I would like a single message for many attachments.

    Can anyone help?

    --|ANDY|--

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