melodiesoflife
asked on
Launch OutLook
Hi all
I in my program, I want to launch OutLook and put something in the body of mail.
I do like that:
'Declare
Private Const SW_SHOW = 1
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
'*******************
Sub Navigate(ByVal NavTo As String)
Dim hBrowse As Long
hBrowse = ShellExecute(0&, "open", NavTo, "", "", SW_SHOW)
End Sub
Then I call Navigate like that:
Navigate "mailto:someone@somewhere. com?subjec t=" & _
"My subject&body=" & _
strText1 & vbCrLf & strText2
I insert vbCrlf because I want an empty line between strText1 and strText2. But it don't has any effect.
How can I insert an empty line between strText1 and strText2?
I in my program, I want to launch OutLook and put something in the body of mail.
I do like that:
'Declare
Private Const SW_SHOW = 1
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
'*******************
Sub Navigate(ByVal NavTo As String)
Dim hBrowse As Long
hBrowse = ShellExecute(0&, "open", NavTo, "", "", SW_SHOW)
End Sub
Then I call Navigate like that:
Navigate "mailto:someone@somewhere.
"My subject&body=" & _
strText1 & vbCrLf & strText2
I insert vbCrlf because I want an empty line between strText1 and strText2. But it don't has any effect.
How can I insert an empty line between strText1 and strText2?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Should it be "%0B" instead of "%0B%08"? fanpages ;-)
First one is "%0B" (that's capital "b" as this is the octal code for decimal 13 - a carriage return), the second one is "%08" - the octal code for line feed (decimal 10).
Together you get <CR><LF>.
If you just want a <CR> use "%0B" or just a <LF> use "%08".
BFN,
fp.
Together you get <CR><LF>.
If you just want a <CR> use "%0B" or just a <LF> use "%08".
BFN,
fp.
ASKER
Hi fanpages
I have try but it don't effect.
When strText1 = "a" and strText2 = "b" I hope the result in outlook is:
a
b
but it show a strange character: a b
'************************* ********** ****
Hi ryancys
When use Outlook.Application and so on, I must register library before used but I can't find it, where it is?
I have try but it don't effect.
When strText1 = "a" and strText2 = "b" I hope the result in outlook is:
a
b
but it show a strange character: a b
'*************************
Hi ryancys
When use Outlook.Application and so on, I must register library before used but I can't find it, where it is?
Hi,
Is your MS-Outlook e-mail set to HTML format as default?
BFN,
fp.
Is your MS-Outlook e-mail set to HTML format as default?
BFN,
fp.
Sorry... may just be a "quirk" of MS-Outlook.
I tried two %0B characters & this seemed to be OK!
mailto:someone@somewhere.c om?subject =My subject&body=body%0B%0Bbod y2
Results in:
===
body
body2
===
In the message text.
BFN,
fp.
I tried two %0B characters & this seemed to be OK!
mailto:someone@somewhere.c
Results in:
===
body
body2
===
In the message text.
BFN,
fp.
>>When use Outlook.Application and so on, I must register library before used but I can't find it, where it is?
In the case you need to use Outlook Objects in your application, you Must include the Library from the References, you Should able to find the M$ Outlook Object Library from References (goto menu Project > References) IF you installed the M$ Outlook in your machine.
In the case you need to use Outlook Objects in your application, you Must include the Library from the References, you Should able to find the M$ Outlook Object Library from References (goto menu Project > References) IF you installed the M$ Outlook in your machine.
ASKER
Hi ryancys
I installed the MS Outlook, but I don't see Outlook Object Library in Referrences dialog.
Do you have any suggest
I installed the MS Outlook, but I don't see Outlook Object Library in Referrences dialog.
Do you have any suggest
Hi again,
Did:
mailto:someone@somewhere.c om?subject =My subject&body=body%0B%0Bbod y2
Not work?
Or are you just trying alternate method(s)?
BFN,
fp.
Did:
mailto:someone@somewhere.c
Not work?
Or are you just trying alternate method(s)?
BFN,
fp.
Try find the "Microsoft Outlook 9.0 Object Library" from References (10.0 for XP, etc)
if still Not found, simply click the Browse, the go to:
<Office or Outlook install folder>\Office\MSOUTL9.OLB (9.0, for 10.0 look for something like MSOUTL10.OLB)
Example:
C:\Program Files\Office2000\Office\MS OUTL9.OLB
select the file then click the Open button. And Now the Library should added to the list.
regards
if still Not found, simply click the Browse, the go to:
<Office or Outlook install folder>\Office\MSOUTL9.OLB
Example:
C:\Program Files\Office2000\Office\MS
select the file then click the Open button. And Now the Library should added to the list.
regards
ASKER
Hi ryancys.
well, I see. But what happen if my customer's computer don't install MS Office (I see that MSOUTL9.OLB is installed when I install MS Outlook).
I only want to use Outlook Express, which included in Window, I don't want to install anythings else.
'********************
Hi fanpages.
mailto:someone@somewhere.c om?subject =My subject&body=body%0B%0Bbod y2
I don't know why but it still not work.
well, I see. But what happen if my customer's computer don't install MS Office (I see that MSOUTL9.OLB is installed when I install MS Outlook).
I only want to use Outlook Express, which included in Window, I don't want to install anythings else.
'********************
Hi fanpages.
mailto:someone@somewhere.c
I don't know why but it still not work.
ASKER
Hi fanpages
I found it. not %0B%08. It must %0D%0A.
That mean 13 and 10 in hexa
I found it. not %0B%08. It must %0D%0A.
That mean 13 and 10 in hexa
Hi,
Glad you found a solution in the end.
Yes, I would ordinarily use ASCII code 13 (decimal) for <CR> & 10 (decimal) for <LF>.
In fact there are too in-built VB/VBA constants vbCR & vbLF (and also vbCRLF) that are set to these values; you may like to use those.
The %0B%0B [double zero 'B'] works via HTML!?!
Yet another Micro$o£t oddity.
Thanks for the points/grading.
Happy codin',
BFN,
fp.
[http://NigelLee.info]
Glad you found a solution in the end.
Yes, I would ordinarily use ASCII code 13 (decimal) for <CR> & 10 (decimal) for <LF>.
In fact there are too in-built VB/VBA constants vbCR & vbLF (and also vbCRLF) that are set to these values; you may like to use those.
The %0B%0B [double zero 'B'] works via HTML!?!
Yet another Micro$o£t oddity.
Thanks for the points/grading.
Happy codin',
BFN,
fp.
[http://NigelLee.info]
>>But what happen if my customer's computer don't install MS Office
Ya, that's the sad place, if you can use the Outlook Library, sure your presentation will be better.
or you can try use this free component to send mail instead:
vbSendMail.dll Version 3.65-- Easy E-mail Sending in VB, with Attachments
http://www.freevbcode.com/ShowCode.Asp?ID=109
cheers
Ya, that's the sad place, if you can use the Outlook Library, sure your presentation will be better.
or you can try use this free component to send mail instead:
vbSendMail.dll Version 3.65-- Easy E-mail Sending in VB, with Attachments
http://www.freevbcode.com/ShowCode.Asp?ID=109
cheers
Example on the "Send Now" button:
Private Sub cmdSendNow_Click()
Dim iOutlook As Outlook.Application
Dim myApp As Outlook.MailItem
Set iOutlook = New Outlook.Application
Set myApp = iOutlook.CreateItem(olMail
temp = "Username"
txtMessage = "Hello World Again!"
AttachFile = "C:\Documents and Settings\Administrator\My Documents\My Pictures\next.gif"
myApp.To = "user@domain.com"
myApp.Subject = "Hello World!"
myApp.Attachments.Add AttachFile
myApp.Body = "Hi " & temp & vbCrLf & vbCrLf & txtMessage
'myApp.HTMLBody = ""
myApp.Send
Do While iOutlook.GetNamespace("MAP
DoEvents
Loop
MsgBox "Successfully Sent", vbInformation, "Email Sent"
End Sub
Customize the example above to suit your requirement, i think this will be the most effective way to present your application.
Hope this helps