User Name
Password

Go Back   Planetarion Forums > Non Planetarion Discussions > Programming and Discussion

Reply
Thread Tools Display Modes
Unread 30 Jan 2003, 16:10   #1
Not_RIT
Registered User
 
Join Date: Jan 2003
Posts: 340
Not_RIT is an unknown quantity at this point
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
Not_RIT is offline   Reply With Quote
Unread 30 Jan 2003, 16:54   #2
JetLinus
Friendly geek of GD :-/
 
JetLinus's Avatar
 
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
JetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud of
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:
  1. 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...
  2. 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.
  3. 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! :-/
JetLinus is offline   Reply With Quote
Unread 30 Jan 2003, 16:55   #3
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
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!!!
Gayle29uk is offline   Reply With Quote
Unread 30 Jan 2003, 17:04   #4
Raging.Retard
Street Tramp
 
Raging.Retard's Avatar
 
Join Date: Apr 2000
Location: Street Gutter
Posts: 341
Raging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant future
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.
Raging.Retard is offline   Reply With Quote
Unread 30 Jan 2003, 17:09   #5
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
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!!!
Gayle29uk is offline   Reply With Quote
Unread 30 Jan 2003, 17:17   #6
Raging.Retard
Street Tramp
 
Raging.Retard's Avatar
 
Join Date: Apr 2000
Location: Street Gutter
Posts: 341
Raging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant futureRaging.Retard has a brilliant future
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.
Raging.Retard is offline   Reply With Quote
Unread 30 Jan 2003, 17:18   #7
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
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!!!
Gayle29uk is offline   Reply With Quote
Unread 30 Jan 2003, 17:28   #8
Not_RIT
Registered User
 
Join Date: Jan 2003
Posts: 340
Not_RIT is an unknown quantity at this point
Gayle the machines which the program will be run on will have outlook, but it wont be set up... so will yours still work?
Not_RIT is offline   Reply With Quote
Unread 30 Jan 2003, 17:31   #9
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
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!!!
Gayle29uk is offline   Reply With Quote
Unread 30 Jan 2003, 17:34   #10
Not_RIT
Registered User
 
Join Date: Jan 2003
Posts: 340
Not_RIT is an unknown quantity at this point
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
Not_RIT is offline   Reply With Quote
Unread 30 Jan 2003, 17:35   #11
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
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!!!
Gayle29uk is offline   Reply With Quote
Unread 30 Jan 2003, 17:46   #12
Not_RIT
Registered User
 
Join Date: Jan 2003
Posts: 340
Not_RIT is an unknown quantity at this point
Quote:
Originally posted by Gayle28uk
What do they use?
A dodgy web interface outlook.
Not_RIT is offline   Reply With Quote
Unread 30 Jan 2003, 17:54   #13
Gayle29uk
Bitch
 
Join Date: Jun 2002
Location: North Yorkshire
Posts: 3,848
Gayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really niceGayle29uk is just really nice
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!!!
Gayle29uk is offline   Reply With Quote
Unread 30 Jan 2003, 17:58   #14
Not_RIT
Registered User
 
Join Date: Jan 2003
Posts: 340
Not_RIT is an unknown quantity at this point
Quote:
Originally posted by Gayle28uk
I don't know then

Every method I know involves either using CDONTS or Outlook


It doesnt really matter, it was more of an 'extra' for the program. Thanks for the help
Not_RIT is offline   Reply With Quote
Unread 30 Jan 2003, 22:08   #15
JetLinus
Friendly geek of GD :-/
 
JetLinus's Avatar
 
Join Date: Nov 2000
Location: On my metal roid
Posts: 923
JetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud ofJetLinus has much to be proud of
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! :-/
JetLinus is offline   Reply With Quote
Unread 31 Jan 2003, 10:30   #16
Mong
Forever Delayed
 
Join Date: Sep 2000
Location: www.netgamers.org
Posts: 1,475
Mong is on a distinguished road
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"
Mong is offline   Reply With Quote
Unread 31 Jan 2003, 11:34   #17
BuddhistPunk
Registered User
 
Join Date: Apr 2002
Location: Leeds, but looking for a way to escape
Posts: 128
BuddhistPunk is an unknown quantity at this point
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
BuddhistPunk is offline   Reply With Quote
Unread 31 Jan 2003, 14:31   #18
Not_RIT
Registered User
 
Join Date: Jan 2003
Posts: 340
Not_RIT is an unknown quantity at this point
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
Not_RIT is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Forum Jump


All times are GMT +1. The time now is 06:02.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2002 - 2018