Use Outloook to send email with specified "From" address

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
mikephillips
Posts: 30
Joined: Wed Jan 27, 2016 6:43 pm

Use Outloook to send email with specified "From" address

Post by mikephillips »

Thanks to Andrew P I can send emails successfully using his code

Code: Select all

Sub UseOutlook( )
  Dim oOLEService
  Dim oOutlookApp
  Dim oOutlookMail

  oOLEService = createUnoService("com.sun.star.bridge.OleObjectFactory")
  oOutlookApp = oOLEService.createInstance("Outlook.Application")
  oOutlookMail = oOutlookApp.CreateItem(0)

  REM I can directly set the recipients by setting the To property
  oOutlookMail.To = "andrew@pitonyak.org"

  REM I can also add to the list, but in my experiments, this access the
  REM mail box so Outlook asks me if I can do this. In other words, it then
  REM requires user interaction. I can probably set the security in outlook
  REM to simply allow this, but then I have opened things for virus activity.
  'oOutlookMail.Recipients.Add("andrew@pitonyak.org")
  
  oOutlookMail.Subject = "Test Subject"
  oOutlookMail.Body = "This is my body text for the email message"

  REM You can also add attachements to the message
  'oOutlookMail.Attachments.Add("C:\foo.txt")

  REM I can display and edit the message
  'oOutlookMail.Display()

  REM Or I can send the message
  'oOutlookMail.send()
End Sub
My query is can I change the 'sending' address? "oOutlookMail.From" does not work?

 Edit: Changed subject, was Using Outlook to send emails 
Make your post understandable by others 
-- MrProgrammer, forum moderator 
Last edited by MrProgrammer on Thu Aug 17, 2023 4:34 pm, edited 1 time in total.
Reason: Edited topic's subject
Open Office 4.0.1 on Windows 7
User avatar
karolus
Volunteer
Posts: 1236
Joined: Sat Jul 02, 2011 9:47 am

Re: Using Outlook to send emails

Post by karolus »

there is NO NEED to teach YOU how to fake Email-addresses
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
detroitlibertyp
Posts: 14
Joined: Wed Oct 17, 2018 5:56 pm
Location: Americas

Re: Using Outlook to send emails

Post by detroitlibertyp »

There is NO NEED to be Rude.
If you don't want to help just don't answer.
Windows 10 X-OpenOffice 4.1.13_rev5
User avatar
Zizi64
Volunteer
Posts: 11497
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Using Outlook to send emails

Post by Zizi64 »

Use a real email client software, like the Thunderbird. You can control it through the LO API.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
mikephillips
Posts: 30
Joined: Wed Jan 27, 2016 6:43 pm

Re: Using Outlook to send emails

Post by mikephillips »

Well! Hopefully the men in white coats will be along soon for 'karolus' (if I even understood the rubbish...). :-)

detroit/zizi thanks. Problem is I do not want to change the default email programme. I take it no-one knows how to write the construct for the 'send' address on this?
Open Office 4.0.1 on Windows 7
User avatar
robleyd
Moderator
Posts: 5465
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: Using Outlook to send emails

Post by robleyd »

I take it no-one knows how to write the construct
It is quite possible that someone does know; as it is only a couple of hours since you posted, you might allow a little time for further responses.
Slackware 15 64 bit
Apache OpenOffice 4.1.16
LibreOffice 25.8.3.2; SlackBuild for 25.8.3 by Eric Hameleers
---------------
I hate this damn computer, I wish that I could sell it.
It won't do what I want it to, Only what I tell it.
mikephillips
Posts: 30
Joined: Wed Jan 27, 2016 6:43 pm

Re: Using Outlook to send emails

Post by mikephillips »

I took the answer from Zizi who is a resident expert to be the final answer, 'cos if he doesn't know.....................!
Open Office 4.0.1 on Windows 7
User avatar
karolus
Volunteer
Posts: 1236
Joined: Sat Jul 02, 2011 9:47 am

Re: Using Outlook to send emails

Post by karolus »

mikephillips wrote: Thu Aug 17, 2023 12:17 pm (if I even understood the rubbish...). :-)
Oh sorry then I guess I overestimated your intelligence!
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
User avatar
Zizi64
Volunteer
Posts: 11497
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Using Outlook to send emails

Post by Zizi64 »

Problem is I do not want to change the default email programme.
The OpenOffice worked fine for me with the old MS Outlook Express software (that was not same nor even similar as the Outlook). Because it was a real email client software (supports the MAPI).

The LibreOffice works fine with the ThunderBird because that is a real email client software too. (I can send you macro examples for it)

I just tried (I am not using now) an another free alternative email client (I not remember the name), and it worked, because it was a real email client software.


Just search in the Forums: You will see that the OutLook - AOO/LO pair is a more problamatic way.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
mikephillips
Posts: 30
Joined: Wed Jan 27, 2016 6:43 pm

Re: Use Outloook to send email with specified "From" address

Post by mikephillips »

Just search in the Forums: You will see that the OutLook - AOO/LO pair is a more problamatic way.
Take it from me - I don't need to search the forums' to find that out................. :-)
Open Office 4.0.1 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31355
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Use Outloook to send email with specified "From" address

Post by Villeroy »

Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
detroitlibertyp
Posts: 14
Joined: Wed Oct 17, 2018 5:56 pm
Location: Americas

Re: Using Outlook to send emails

Post by detroitlibertyp »

mikephillips wrote: Thu Aug 17, 2023 12:17 pm detroit/zizi thanks. Problem is I do not want to change the default email programme. I take it no-one knows how to write the construct for the 'send' address on this?
It's certainly your right, though I do wonder why someone who is smart enough to use OpenOffice why they wouldn't similarly want to use a Free Software email client like Thunderbird.

Then again I say that as someone who has in his siganture that he's using Windows, because it's required by my employer and the only reason I'm using the old and busted portable version of x-openOffice is that for some reason it doesn't throw off the IT security stuff, while newer versions, including anything of LO does.
Last edited by detroitlibertyp on Thu Aug 17, 2023 6:09 pm, edited 1 time in total.
Windows 10 X-OpenOffice 4.1.13_rev5
detroitlibertyp
Posts: 14
Joined: Wed Oct 17, 2018 5:56 pm
Location: Americas

Re: Use Outloook to send email with specified "From" address

Post by detroitlibertyp »

Villeroy wrote: Thu Aug 17, 2023 5:41 pm viewtopic.php?t=90298
Villeroy, this looks awesome! Do you know if it works with current version of Microsoft Outlook? I only ask because OP indicated that the way he had been doing it worked with the earlier version of Outlook Express, which IIUC, is no longer supported.
Windows 10 X-OpenOffice 4.1.13_rev5
mikephillips
Posts: 30
Joined: Wed Jan 27, 2016 6:43 pm

Re: Use Outloook to send email with specified "From" address

Post by mikephillips »

Perhaps time to repeat my initial question in the hope someone might know.
My query is can I change the 'sending' address? "oOutlookMail.From" does not work?
This forum is 'amazing'. Even ignoring the 'problem child', we have gone from a simple question to Python and heaven knows where else. I have to assume that there is no way to set up a chosen 'From' address in Andrew's script.
Open Office 4.0.1 on Windows 7
User avatar
Villeroy
Volunteer
Posts: 31355
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Use Outloook to send email with specified "From" address

Post by Villeroy »

detroitlibertyp wrote: Thu Aug 17, 2023 6:03 pm
Villeroy wrote: Thu Aug 17, 2023 5:41 pm viewtopic.php?t=90298
Villeroy, this looks awesome! Do you know if it works with current version of Microsoft Outlook? I only ask because OP indicated that the way he had been doing it worked with the earlier version of Outlook Express, which IIUC, is no longer supported.
This is a tiny macro which sends email pulling the addresses, subjects and mail bodies from a spreadsheet. It works without any Outlook, even on non-Windows PCs.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
karolus
Volunteer
Posts: 1236
Joined: Sat Jul 02, 2011 9:47 am

Re: Use Outloook to send email with specified "From" address

Post by karolus »

Villeroy wrote: Thu Aug 17, 2023 9:45 pm ]
This is a tiny macro which sends email pulling the addresses, subjects and mail bodies from a spreadsheet. It works without any Outlook, even on non-Windows PCs.
…But unfortunately it takes 10 minutes to read the instructions, fill in the mail providers login data ( !!! including a valid sender address !!!) ect.

So it is not suitable for @OP and @detroidlibertyp :roll:
Libreoffice 25.2… on Debian 13 (trixie) (on RaspberryPI5)
Libreoffice 25.8… flatpak on Debian 13 (trixie) (on RaspberryPI5)
Post Reply