Sending a csv file to a ftp site.

Godot60

Board Regular
Joined
May 11, 2017
Messages
62
I have written a macro that sends a sheet as a csv file to an email address. What if I want to send it to an FTP site instead? Not sure how I would change my code. Any advice would be appreciated.

Sub Mail_small_Text_Outlook2()


If Range("c157").Value = "" Or Range("c159").Value = "" Then
MsgBox "Please complete all required fields"
Exit Sub
End If


Sheets("iCIMS").Visible = True

Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String
Dim CSVfileName As String
CSVfileName = ActiveWorkbook.Path & "\ICIMS.csv"
ActiveWorkbook.Worksheets("ICIMS").Copy
ActiveWorkbook.SaveAs CSVfileName, FileFormat:=xlCSV
ActiveWorkbook.Close False

Sheets("Icims").Visible = False

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
strbody = "Title: " & Sheet1.Range("A4") & vbNewLine & _
"Department: " & Sheet1.Range("C4") & vbNewLine & _
"SBU: " & Sheet1.Range("B5") & vbNewLine & _
"Level: " & Sheet1.Range("B6") & vbNewLine & _
"Manager: " & Sheet1.Range("B145")


On Error Resume Next


With OutMail
.To = "bill.jones@college.edu"
.cc = ""
.BCC = ""
.Subject = "Successful Submission: " & Sheet1.Range("a4")
.Body = strbody
.Attachments.Add CSVfileName


.Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Thanks. Not sure how to incorporate this into my existing code which requires certain fields to be completed before the document can be sent. Suggestions?
 
Upvote 0
Just put your

Code:
If Range("c157").Value = "" Or Range("c159").Value = "" Then
    MsgBox "Please complete all required fields"
    Exit Sub
End If
before the first InputBox line.

Of course you might decide to hard-code the username and password in the code or get them from cells, in which case the InputBox prompts aren't needed.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top