Jump to content

How to open .CSV file and attach it in my Gmail Account


Trisha
 Share

Recommended Posts

I tried (using AutoIt) to automate a scenario where Internet Explorer will open a specific URL. Next I click on a link to download a .doc file. Then I want to open this file and attach it in my Gmail Account.

I did as far as the download step. Now, how would I open the file which is stored in Downloads folder, and attach in Gmail?

The sample code below is not opening the file as expected:

WinActivate("Downloads")
Sleep(2000)
;Local Const $sTestPath = _PathFull("C:\Users\camanjana\Downloads\xyz.doc")
$hFile = Fileopen("xyz.doc")
$FileContent = FileRead($hFile)
FileClose($hFile) 
Link to comment
Share on other sites

2 minutes ago, Trisha said:

I tried (using AutoIt) to automate a scenario where Internet Explorer will open a specific URL. Next I click on a link to download a .doc file. Then I want to open this file and attach it in my Gmail Account.

I did as far as the download step. Now, how would I open the file which is stored in Downloads folder, and attach in Gmail?

The sample code below is not opening the file as expected:


WinActivate("Downloads")
Sleep(2000)
;Local Const $sTestPath = _PathFull("C:\Users\camanjana\Downloads\xyz.csv")
$hFile = Fileopen("xyz.csv")
$FileContent = FileRead($hFile)
FileClose($hFile) 
Link to comment
Share on other sites

I tried (using AutoIt) to automate a scenario where Internet Explorer will open a specific URL. Next I click on a link to download a .doc file. Then I want to open this file and attach it in my Gmail Account.

I did as far as the download step. Now, how would I open the file which is stored in Downloads folder, and attach in Gmail? Please help me with the issue.

The sample code below is not opening the file as expected:

WinActivate("Downloads")
Sleep(2000)
;Local Const $sTestPath = _PathFull("C:\Users\camanjana\Downloads\xyz.csv")
$hFile = Fileopen("xyz.csv")
$FileContent = FileRead($hFile)
FileClose($hFile) 
Link to comment
Share on other sites

Trisha,

How do you know it is not being opened?  Try running it like this...

WinActivate("Downloads")
Sleep(2000)
;Local Const $sTestPath = _PathFull("C:\Users\camanjana\Downloads\xyz.csv")
$hFile = Fileopen("xyz.csv")
if $hFile = -1 then exit msgbox(17,'Error','File open error')
$FileContent = FileRead($hFile)
msgbox(0,'',$FileContent)
FileClose($hFile)

What is the WinActivate for?

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Link to comment
Share on other sites

Hi Trisha,

The link below discusses your problem pretty well.

If you do your searching from google instead of the search window in this form and use the term "AutoIT ThingUWantToDoHere" there's a huge amount of quality advice.  Great community here.

You don't need to open the file.  Just attached it as the example above shows

 

Edited by gruntydatsun
Link to comment
Share on other sites

9 hours ago, Trisha said:

Hello kylomas, 

I was trying to give focus to "Downloads" folder, because the .CSV file is there only.

 

In your code above "WinActivate("Downloads")" give focus (i.e. highlights) a "window" on your screen, not to the script. You were on the correct track with 

;Local Const $sTestPath = _PathFull("C:\Users\camanjana\Downloads\xyz.csv")
$hFile = Fileopen("xyz.csv")

Either uncomment the "Local Const $sTestPath.....bla..bla.... and use that variable as the argument in the Fileopen function of the next line or add the quoted full path as the argument.

However gruntydatsun link and suggestion will take you to your final goal. 

Link to comment
Share on other sites

  • Moderators

@Trisha please stick to one thread in the future.  Spamming your question multiple times on the forum is not going to get you an answer any more quickly.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

@gruntydatsun Thank you for your hint. Now i was trying to do with Outlook. There is one UDF related to Outlook, And i tried to add in Scite  config tool, But after finishing it. when i reopen the Scite Editor , Its not working.Please help me out with this.

Sorry for this silly question :-) 

outbox.JPG

Link to comment
Share on other sites

@water could you please help me out with the scenario , where i want to send mail through outlook to more than one people with attachment.

I tried your scripts OutlookEX one. and i wrote code accordingly:

Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

Global $sCurrentUser = $oOutlook.GetNameSpace("MAPI").CurrentUser.Name

;_OL_Wrapper_SendMail($oOutlook, $sCurrentUser, sucheta.deb@accenture.com, "", "", "TestSubject", "Testing Purpose", @ScriptDir & "\_Excel.csv", $olFormatHTML, $olImportanceHigh)
;If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Error sending mail. @error = " & @error & ", @extended: " & @extended)
;MsgBox(64, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Mail successfully sent to user '" & $sCurrentUser & "'!")

;Sending Mail

Global $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "*\Outlook-UDF-Test\TargetFolder\Mail", "", _
  "Subject=TestMail", "BodyFormat=" & $olFormatHTML, "HTMLBody=Bodytext in <b>bold</b>.", "To=anjana.prajapati@company.com;xyz.asag@company.com")
; Send the mail
Global $aOL_Item = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test\SourceFolder\Mail", $olMail, "", "", "", "EntryID")
Global $oItem1 = _OL_ItemAttachmentAdd($oOutlook, $aOL_Item[1][0], Default, @ScriptDir & "\_Excel.csv")
_OL_ItemSend($oOutlook, $oItem)
 

Link to comment
Share on other sites

  • 3 weeks later...

I'm, a bit late. Sorry about that.
This script works for me:

#include <OutlookEX.au3>

Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

Global $oItem = _OL_ItemCreate($oOutlook, $olMailItem, "", "", _
        "Subject=TestMail", "BodyFormat=" & $olFormatHTML, "HTMLBody=Bodytext in <b>bold</b>.", "To=Jon.Doe@company.com;Jane.Doe@company.com")

_OL_ItemAttachmentAdd($oOutlook, $oItem, Default, @ScriptDir & "\_Excel.csv")
_OL_ItemSend($oOutlook, $oItem)

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Glad you Like this UDF ;) 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@water Need your help again :) How can I move from my host machine(currently I am using windows 10) to VMware. I ran the VMware.exe, after giving login credential VMWare got open but I am not able to run any application "using run("xyz.exe"), I think VMWare window itself is not getting activated. Below is my code:

Run("C:\Program Files (x86)\VMware\VMware Horizon View Client\vmware-view")
WinWaitActive("VMware Horizon Client")
MouseClick("left",193,292,2)
WinWaitActive("Login")
Send("feb@2018")
Send("{TAB}")
Send("{TAB}")
Send("{Enter}")
If WinExists("VMware Horizon Client") Then
 WinWaitActive("VMware Horizon Client")
  MouseClick("left",224,274,2)
EndIf

WinWaitActive("alcala")
Run(xyz.exe)

Link to comment
Share on other sites

Run always executes on the machine you run your AutoIt script.
The VMWare client is just another computer in the network. Use PSExec ore something similar to start xyz.exe on this c omputer.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...