Need Help About Finding AutoFill Setting

sg34

New Member
Joined
Mar 19, 2023
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
Hello,

In the attached excel file in the link below, when I hit the `send to email` it opens a new outlook email window and copies the selected information from the same excel file.
I want to find out how I can change the email domain prifix that comes in the `To`section. currently it comes automatically as ...@outlook.com, How I can change the @outlook.com to be something else that I want.
Also in the CC section it always brings my email address, dont know how it finds my email address! I need to change this one too.

Appreciate if someone could help
Thanks in advance.

 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
VBA Code:
Sub SendPDF()
' Create PDF of active sheet and send as attachment.
'

Sheets("Zimmet_Laptop_Orjinal").Select

    Dim rng As Range
    Dim strPath As String, strFName As String
    Dim OutApp As Object, OutMail As Object
    
    
     'Create PDF of active sheet only
    strPath = Environ$("temp") & "\" 'Or any other path, but include trailing "\"
    
    strFName = ActiveWorkbook.Name
    'strFName = Left(strFName, InStrRev(strFName, ".") - 1) & "_" & Range("A2") & ".pdf"
    strFName = Range("o4") & " " & "Zimmet_Formu" & ".pdf"
    
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
        strPath & strFName, Quality:=xlQualityStandard, _
        IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
        
     'Set up outlook
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)

    Set rng = Nothing
    On Error Resume Next
    Set rng = Sheets("Zimmet_Laptop_Orjinal").Range("p5:y18").SpecialCells(xlCellTypeVisible)
    On Error GoTo 0

     'Create message
    On Error Resume Next
    With OutMail
        .to = Range("o7").Value
        .CC = Range("o8").Value
        .BCC = ""
        .Subject = "IT Ekipmani Teslim Alma Formu" & "" & Range("I35") & " " & " " & Range("Q5")
        '.Body = "Insert Body Text Here." & vbCr & "Best regards, etc." & vbCr
        .HTMLBody = RangetoHTML(rng)
        .Attachments.Add strPath & strFName
        .Display   'Use only during debugging ##############################
        '.Send      'Uncomment to send e-mail ##############################
    End With

     'Delete any temp files created
    Kill strPath & strFName
    Sheets("IT_Demirbas").Select
    Range("A5").AutoFilter Field:=1, Criteria1:=Range("C2")
    Set oOutlook = GetObject(, "Outlook.Application")
    
    On Error GoTo 0

    Set OutMail = Nothing
    Set OutApp = Nothing
   
End Sub
 
Upvote 0
VBA Code:
Option Explicit

Function RangetoHTML(rng As Range)
' Changed by Ron de Bruin 28-Oct-2006
' Working in Office 2000-2010
    Dim fso As Object
    Dim ts As Object
    Dim TempFile As String
    Dim TempWB As Workbook
 
    TempFile = Environ$("temp") & "\" & Format(Now, "dd-mm-yy h-mm-ss") & ".htm"
 
    'Copy the range and create a new workbook to past the data in
    rng.Copy
    Set TempWB = Workbooks.Add(1)
    With TempWB.Sheets(1)
        .Cells(1).PasteSpecial Paste:=8
        .Cells(1).PasteSpecial xlPasteValues, , False, False
        .Cells(1).PasteSpecial xlPasteFormats, , False, False
        .Cells(1).Select
        Application.CutCopyMode = False
        On Error Resume Next
        .DrawingObjects.Visible = True
        .DrawingObjects.Delete
        On Error GoTo 0
    End With
 
    'Publish the sheet to a htm file
    With TempWB.PublishObjects.Add( _
         SourceType:=xlSourceRange, _
         Filename:=TempFile, _
         Sheet:=TempWB.Sheets(1).Name, _
         Source:=TempWB.Sheets(1).UsedRange.Address, _
         HtmlType:=xlHtmlStatic)
        .Publish (True)
    End With
 
    'Read all data from the htm file into RangetoHTML
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
    RangetoHTML = ts.readall
    ts.Close
    RangetoHTML = Replace(RangetoHTML, "align=center x:publishsource=", _
                          "align=left x:publishsource=")
 
    'Close TempWB
    TempWB.Close savechanges:=False
 
    'Delete the htm file we used in this function
    Kill TempFile
 
    Set ts = Nothing
    Set fso = Nothing
    Set TempWB = Nothing
End Function

 
Function GetBoiler(ByVal sFile As String) As String
'**** Kusleika
    Dim fso As Object
    Dim ts As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
    GetBoiler = ts.readall
    ts.Close
End Function
 
Upvote 0
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub
 
Upvote 0
To change the email domain prefix that comes in the To section, you need to modify the .To property of the OutMail object. Currently, the email address is being taken from cell O7 in the worksheet "Zimmet_Laptop_Orjinal", so you can change the value in that cell to the email address you want to send the email to.

To change the email domain, replace the domain name in the email address in cell O7 with the domain name you want to use.

For example, if you want to send the email to john@example.com, you would change cell O7 to "john@yourdomain.com".

To change the email address in the CC section, you need to modify the .CC property of the OutMail object. Currently, the email address is being taken from cell O8 in the worksheet "Zimmet_Laptop_Orjinal", so you can change the value in that cell to the email address you want to CC the email to.

You can change the email address in the same way as described for the To section.
 
Upvote 0
To change the email domain prefix that comes in the To section, you need to modify the .To property of the OutMail object. Currently, the email address is being taken from cell O7 in the worksheet "Zimmet_Laptop_Orjinal", so you can change the value in that cell to the email address you want to send the email to.

To change the email domain, replace the domain name in the email address in cell O7 with the domain name you want to use.

For example, if you want to send the email to john@example.com, you would change cell O7 to "john@yourdomain.com".

To change the email address in the CC section, you need to modify the .CC property of the OutMail object. Currently, the email address is being taken from cell O8 in the worksheet "Zimmet_Laptop_Orjinal", so you can change the value in that cell to the email address you want to CC the email to.

You can change the email address in the same way as described for the To section.
Thank you so much!:)
 
Upvote 0

Forum statistics

Threads
1,215,061
Messages
6,122,922
Members
449,094
Latest member
teemeren

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