|
30 Jan 2003, 16:10
|
#1
|
Registered User
Join Date: Jan 2003
Posts: 340
|
email using VBA? (gayle!)
I am looking to send email within an aplication, something simliar to the php email scripts you get, if anyone knows the VBA API calls or knows how to do this I would be greatful
|
|
|
30 Jan 2003, 16:54
|
#2
|
Friendly geek of GD :-/
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
|
Re: email using VBA? (gayle!)
Quote:
Originally posted by Not_RIT
I am looking to send email within an aplication, something simliar to the php email scripts you get, if anyone knows the VBA API calls or knows how to do this I would be greatful
|
Ok I do know of 3 different methods:
- The hard way: Use Winsock. Either API calls or the Winsock Control (OCX), then implement your own version of the SMTP protocol (just some basic commands), and voila, you got your mail sent...
- Use some MAPI Calls or Controls. I think you can get them for free or they come with Outlook (Express)? Usage is not that complicated, but you cant do as much with it as using the 1st method.
- Try to find out if there are any other build-in methods, like ready-made scripts or calls especially for VBA. (Some MS Outlook stuff maybe?)
__________________
[ »] Entropy increases! :-/
|
|
|
30 Jan 2003, 16:55
|
#3
|
Bitch
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
|
Code:
Private Sub SendMail()
Dim OutlookObj As Object
Dim Msg As Object
Const OutlookMailItem = 0
Set OutlookObj = CreateObject("Outlook.Application")
Set Msg = OutlookObj.CreateItem(OutlookMailItem)
With Msg
.Subject = "Insert subject here"
.To = "Insert recipients here"
.Body = "Insert body of message here. "
.Send
End With
End Sub
Et voila
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
|
|
|
30 Jan 2003, 17:04
|
#4
|
Street Tramp
Join Date: Apr 2000
Location: Street Gutter
Posts: 341
|
The outlook component is bulky (and I guess presumes you have Outlook installed?). I suspect its more efficient to use the CDONTS if VBA supports it? (Been a LONG while).
Code:
Private Sub SendMail()
' Create Mail Object
Dim objMail As Object
Set objMail = CreateObject("CDONTS.NewMail")
' Fill Properties
objMail.From = "etc"
objMail.To = "etc"
objMail.Subject = "etc"
objMail.Body = "etc"
' Send Mail
objMail.Send
'Clean Up
Set objMail = Nothing
End Sub
__________________
Chimney Pots.
|
|
|
30 Jan 2003, 17:09
|
#5
|
Bitch
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
|
Quote:
Originally posted by Raging.Retard
The outlook component is bulky (and I guess presumes you have Outlook installed?). I suspect its more efficient to use the CDONTS if VBA supports it? (Been a LONG while).
|
This assumes you have IIS SMTP running on your machine though and won't work through most corporate firewalls. My code uses Outlook so will work through an Exchange server (which is what I originally wrote it for).
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
|
|
|
30 Jan 2003, 17:17
|
#6
|
Street Tramp
Join Date: Apr 2000
Location: Street Gutter
Posts: 341
|
Quote:
Originally posted by Gayle28uk
This assumes you have IIS SMTP running on your machine though and won't work through most corporate firewalls. My code uses Outlook so will work through an Exchange server (which is what I originally wrote it for).
|
Although the point that my code requires CDONTS is valid, and IIS SMTP does install CDONTS, it is however one of many applications that installs it (Just happens to be the most well known). CDONTS will happily route via MS Exchange if that is the local mail service.
But I guess the assumption that CDONTS would be there is no worse than assuming the Outlook compentent is there. Chances are it will be, but it doesnt have to be.
Still, point taken.
__________________
Chimney Pots.
|
|
|
30 Jan 2003, 17:18
|
#7
|
Bitch
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
|
Quote:
Originally posted by Raging.Retard
CDONTS will happily route via MS Exchange if that is the local mail service.
|
AndI didn't know that so I learnt something new. Bonus \o/
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
|
|
|
30 Jan 2003, 17:28
|
#8
|
Registered User
Join Date: Jan 2003
Posts: 340
|
Gayle the machines which the program will be run on will have outlook, but it wont be set up... so will yours still work?
|
|
|
30 Jan 2003, 17:31
|
#9
|
Bitch
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
|
Quote:
Originally posted by Not_RIT
Gayle the machines which the program will be run on will have outlook, but it wont be set up... so will yours still work?
|
It'll send through whatever medium Outlook is configured for under whatever account is logged in at the time so no, without actually setting up Outlook it won't work
On the plus side as long as Outlook is configured it will work even if Outlook is closed.
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
|
|
|
30 Jan 2003, 17:34
|
#10
|
Registered User
Join Date: Jan 2003
Posts: 340
|
Quote:
Originally posted by Gayle28uk
It'll send through whatever medium Outlook is configured for under whatever account is logged in at the time so no, without actually setting up Outlook it won't work
On the plus side as long as Outlook is configured it will work even if Outlook is closed.
|
It wont work then College computers dont use outlook
|
|
|
30 Jan 2003, 17:35
|
#11
|
Bitch
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
|
Quote:
Originally posted by Not_RIT
It wont work then College computers dont use outlook
|
What do they use?
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
|
|
|
30 Jan 2003, 17:46
|
#12
|
Registered User
Join Date: Jan 2003
Posts: 340
|
Quote:
Originally posted by Gayle28uk
What do they use?
|
A dodgy web interface outlook.
|
|
|
30 Jan 2003, 17:54
|
#13
|
Bitch
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
|
Quote:
Originally posted by Not_RIT
A dodgy web interface outlook.
|
I don't know then
Every method I know involves either using CDONTS or Outlook
__________________
ACHTUNG!!!
Das machine is nicht fur gefingerpoken und mittengrabben. Ist easy
schnappen der springenwerk, blowenfusen und corkenpoppen mit
spitzensparken. Ist nicht fur gewerken by das dummkopfen. Das
rubbernecken sightseeren keepen hands in das pockets. Relaxen und vatch
das blinkenlights!!!
|
|
|
30 Jan 2003, 17:58
|
#14
|
Registered User
Join Date: Jan 2003
Posts: 340
|
|
|
|
30 Jan 2003, 22:08
|
#15
|
Friendly geek of GD :-/
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
|
Quote:
Originally posted by Not_RIT
It doesnt really matter, it was more of an 'extra' for the program. Thanks for the help
|
So you don't wanna do the hardcore STMP programming then?
Ok, and what about installing MAPI from somewhere? I think the libraries ARE installed with Outlook, and you can set up the "account" (i.e. specify server etc) from inside the program.
Just search google or so on how to use MAPI objects in VBA to send mails...
I think it's alsmost as easy as CDONTS (whatever that might be)...
__________________
[ »] Entropy increases! :-/
|
|
|
31 Jan 2003, 10:30
|
#16
|
Forever Delayed
Join Date: Sep 2000
Location: www.netgamers.org
Posts: 1,475
|
What is it you're trying to do anyway? Does it *have* to be done in VBA?
M.
__________________
Firefly Oper and General l4m3r - "I Do Stuff"
O2 Rip-off campaign
<vampy> plus i hate people ... i despise humanity as a whole
pablissimo "I'm still geting over the fact you just posted a pic of your own vomit"
|
|
|
31 Jan 2003, 11:34
|
#17
|
Registered User
Join Date: Apr 2002
Location: Leeds, but looking for a way to escape
Posts: 128
|
Quote:
Originally posted by Not_RIT
A dodgy web interface outlook.
|
If youre email normally runs through a web interface the chances are this works through posting strings to a url (i.e. body, sendto, sendfrom etc etc etc) - unless it some sort of java applet etc
What might be worth investigating is calling the post page, with the necessary variables, from your code. The only requirement of this is that the user has a network connection and that the email page is available.
__________________
SELECT everything FROM everywhere WHERE something = something_else;
> 42
|
|
|
31 Jan 2003, 14:31
|
#18
|
Registered User
Join Date: Jan 2003
Posts: 340
|
Quote:
Originally posted by Mong
What is it you're trying to do anyway? Does it *have* to be done in VBA?
M.
|
Yep it has to be done in VBA
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
|
All times are GMT +1. The time now is 06:02.
| |