|
-
Jun 28th, 2000, 02:20 PM
#1
Thread Starter
Hyperactive Member
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
-
Jun 28th, 2000, 02:47 PM
#2
Or just load Outlook Express ;].
-
Jun 28th, 2000, 03:50 PM
#3
Hyperactive Member
onerrorgoto,
can it work in sending a bitmap attachment file?
-
Jun 28th, 2000, 03:53 PM
#4
Frenzied Member
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."
-
Jun 28th, 2000, 05:09 PM
#5
Thread Starter
Hyperactive Member
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
-
Jun 28th, 2000, 05:28 PM
#6
Addicted Member
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
-
Jun 28th, 2000, 05:30 PM
#7
Addicted Member
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
-
Jun 28th, 2000, 05:49 PM
#8
Addicted Member
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
-
Jun 28th, 2000, 05:59 PM
#9
Addicted Member
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
-
Jun 28th, 2000, 06:27 PM
#10
Hyperactive Member
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?
-
Jun 28th, 2000, 06:40 PM
#11
Thread Starter
Hyperactive Member
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
-
Jun 29th, 2000, 01:56 AM
#12
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
-
Jul 18th, 2000, 05:30 AM
#13
New Member
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?
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
|