+ Reply to Thread
Results 1 to 4 of 4

From feild, CC field needed.. :(

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    01-25-2013
    Location
    Chennai
    MS-Off Ver
    Excel 2003
    Posts
    112

    From feild, CC field needed.. :(

    Hi Guys,

    Below is my working code..

    i need to add from and CC field in the mailing option...

    Can someone help me ?

    Thing is taht FROM and CC both will be the same email address.

    Your help on this will be much appreciated.

    option Explicit
    
    Sub create_sheets()
    Dim wb As Workbook
    Dim i As Long, lrow As Long
    Dim sname As String
    
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    
    With Workbooks("Import Subport Tracker From NEW August-2012").Worksheets("Soumendra")
        lrow = .Range("A" & .Rows.Count).End(xlUp).Row
        For i = 2 To lrow
            If .Range("AA" & i).Value <> "PRO" Then
                sname = .Range("D" & i).Value
                Workbooks.Add
                Set wb = ActiveWorkbook
                ThisWorkbook.Worksheets("Sheet1").Cells.Copy wb.Worksheets(1).Range("A1")
                wb.Worksheets(1).Range("B22").Value = .Range("B" & i).Value
                wb.Worksheets(1).Range("D5").Value = sname
                wb.Worksheets(1).Range("D7").Value = .Range("F" & i).Value
                wb.Worksheets(1).Range("B2").Value = .Range("AA" & i).Value
                wb.Worksheets(1).Range("C30").Value = .Range("H" & i).Value
                wb.Worksheets(1).Range("G27").Value = .Range("I" & i).Value
                wb.Worksheets(1).Range("B14").Value = .Range("j" & i).Value
                wb.Worksheets(1).Range("B18").Value = .Range("K" & i).Value
                wb.Worksheets(1).Range("L12").Value = .Range("G" & i).Value
                wb.Worksheets(1).Range("A6").Value = Format(Now(), "dd/mm/yyyy")
                wb.Worksheets(1).Range("A7").Value = Format(Now(), "H:MM")
                
                With wb.Worksheets(1)
                    If .Range("B14").Value = "OPAL" Then
                        .Range("H14").Value = "820"
                    ElseIf .Range("B14").Value = "BT" Then
                        .Range("H14").Value = "001"
                    ElseIf .Range("B14").Value = "SKY" Then
                        .Range("H14").Value = "822"
                    ElseIf .Range("B14").Value = "TELEWEST" Then
                        .Range("H14").Value = "135"
                    ElseIf .Range("B14").Value = "NTL" Then
                        .Range("H14").Value = "825"
                    End If
                    
                    If .Range("B18").Value = "OPAL" Then
                        .Range("H18").Value = "820"
                    ElseIf .Range("B18").Value = "BT" Then
                        .Range("H18").Value = "001"
                    ElseIf .Range("B18").Value = "SKY" Then
                        .Range("H18").Value = "822"
                    ElseIf .Range("B18").Value = "TELEWEST" Then
                        .Range("H18").Value = "135"
                    ElseIf .Range("B18").Value = "NTL" Then
                        .Range("H18").Value = "825"
                    End If
                End With
                
                If Dir("T:\SGD Z Drive\CW Access Provisioning\Porting Desk\GNP Tesco Import\2013 Tesco\Safi\" & sname & "\") = "" Then
                    MkDir ("T:\SGD Z Drive\CW Access Provisioning\Porting Desk\GNP Tesco Import\2013 Tesco\Safi\" & sname & "\")
                End If
                 
                wb.SaveAs ("T:\SGD Z Drive\CW Access Provisioning\Porting Desk\GNP Tesco Import\2013 Tesco\Safi\" & sname & "\" & sname & "_RH.xls")
            
    RunThisOnError:
           
                Dim iTryAgain  As Integer
                iTryAgain = iTryAgain + 1
                If iTryAgain = 250 Then GoTo GiveUpOnTheEmail
        
              
                If Val(Application.Version) >= 12 Then
                    If wb.FileFormat = 51 And wb.HasVBProject = True Then
                        GoTo GiveUpOnTheEmail
                    End If
                End If
        
                On Error Resume Next
                Dim iLoop As Integer
                For iLoop = 1 To 3
                
                With wb.Worksheets(1)
                
                    If .Range("B18").Value = "OPAL" Then
                            wb.SendMail ("gnp@cw.com"), ("CW_Ports_" & sname & "_RH")
            
                    ElseIf .Range("B18").Value = "BT" Then
                            wb.SendMail ("gnp@cw.com"), ("CW_Single_" & sname & "_RH")
            
                    ElseIf .Range("B18").Value = "SKY" Then
                            wb.SendMail ("gnp@cw.com"), ("CW_Single_" & sname & "_RH")
            
                    ElseIf .Range("B18").Value = "TELEWEST" Then
                            wb.SendMail ("gnp@cw.com"), ("CW_Single_" & sname & "_RH")
            
                    ElseIf .Range("B18").Value = "NTL" Then
                            wb.SendMail ("gnp@cw.com"), ("CW_Single_" & sname & "_RH")
            
                    End If
                                         
                End With
                     If Err.Number = 0 Then Exit For
                Next iLoop
        
                On Error GoTo RunThisOnError
    GiveUpOnTheEmail:
        
                wb.Close
            End If
        Next i
    End With
    
    MsgBox "Done"
    
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
    
    End Sub
    TIA
    Safi

  2. #2
    Forum Contributor
    Join Date
    01-25-2013
    Location
    Chennai
    MS-Off Ver
    Excel 2003
    Posts
    112

    Re: From feild, CC field needed.. :(

    HI Guys,

    I have used Array for CC field...

    But can some one help me to get a code for : SENDING TEH MAIL ON BEHALF OF ?

    Thanks,
    Safi.

  3. #3
    Forum Contributor
    Join Date
    01-25-2013
    Location
    Chennai
    MS-Off Ver
    Excel 2003
    Posts
    112

    Re: From feild, CC field needed.. :(

    Guys ,

    Can some one assist me ??? :'(

    Thanks,
    Safi.

  4. #4
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: From feild, CC field needed.. :(

    Since you have already solved this question yourself and asked the question regarding "sending email on behalf of another" in another thread, i will mark this as solved.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1