Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 05-26-2020, 06:32 AM
Steve2081 Steve2081 is offline Code to add email account Windows 7 64bit Code to add email account Office 2016
Advanced Beginner
Code to add email account
 
Join Date: Apr 2020
Posts: 44
Steve2081 is on a distinguished road
Default Code to add email account

I'm using the below macro/code to convert a word doc to pdf then send it onto outlook. What I'd like is have the code set a specific account from which the email is sent.



Can anyone help?
Reply With Quote
  #2  
Old 05-26-2020, 06:33 AM
Steve2081 Steve2081 is offline Code to add email account Windows 7 64bit Code to add email account Office 2016
Advanced Beginner
Code to add email account
 
Join Date: Apr 2020
Posts: 44
Steve2081 is on a distinguished road
Default

Sub SendAsPDF()
Dim strFileName As String
Dim objOutlook As Object
Dim objMailItem As Object

strFileName = Replace(ActiveDocument.FullName, ".docm", ".pdf")
ActiveDocument.ExportAsFixedFormat OutputFileName:=strFileName, _
ExportFormat:=wdExportFormatPDF

Set objOutlook = CreateObject("Outlook.Application")
Set objMailItem = objOutlook.CreateItem(0) ' 0 = olMailItem
With objMailItem
.Subject = " Leaflet"
.Body = "This email is sent from an account we use for sending messages only. So if you want to contact us please don't reply to this message, do so by following this link for details:"
.To = ""
.Attachments.Add strFileName
.Display
End With

Kill strFileName

Set objMailItem = Nothing
Set objOutlook = Nothing
End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Code to forward an email when moved to a sub folder not in the default account's inbox Shayes Outlook 0 09-18-2017 03:32 PM
code to find account and sum up values Brian13 Excel Programming 2 05-31-2017 09:26 AM
Office 2016 insists on using my MSN email when replying instead of the account the email is on pegasus416 Outlook 0 09-11-2016 08:41 AM
Code to add email account Macro to change font in email, dependent on which email account is being used gb82 Outlook 2 01-23-2016 01:54 AM
Require assistance in writing code to login to webmail account. saurabhlotankar Excel Programming 4 05-21-2015 10:47 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:28 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft